Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/tpy/src/error.ts

๐Ÿ”‘ A strongly typed Pylon API client.
Latest
import * as tpy from "https://deno.land/x/tpy@v1.0.0-RC/src/error.ts";

Tpy's library specific error interface, provides more specific and helpful messages along with direct context with what caused the error.

It is made to be disected and verifiable, as it only comes with set possible outcomes derived from TpyErrors.

Example Error

try {
// ...
} catch (e) {
  if (e instanceof TpyError)
    console.error(`There was an error! ${e.name}: ${e.message()}`);

  // Handle if e suits other Error interfaces.
}

Type casting e implies e will only ever return a TpyError. TpyError does not catch all errors, it should catch most errors regarding the request, though.

Classes

An error wrapper of TpyErrors that provides specific context of the environment to explain why it was thrown.

Variables

The set of errors returned by TpyError that describes a set of error names (keys) which consists of two values: a string description and a method message to create a human-friendly defintion with specific context information.

Functions

Creates a string that describes the parameter(s) are either missing or incompatible.

Clarifies that the string is the response body.

Clarifies that the string is the HTTP response code.

Interfaces

As TpyErrors is a asserted as a const type, it cannot be directly typed out. This is an interface to what shape it takes.