Skip to main content

A JavaScript/TypeScript package providing common utilities and logic shared across all Temboplus-Afloat Projects

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
64%
Published
3 weeks ago (0.1.28)
class APIError
extends Error

Custom error class representing API-related errors. Extends the built-in Error class to include additional properties such as statusCode, error, and details.

Constructors

new
APIError(args: { message: string; statusCode: number; error?: string; details?: Record<string, unknown>; })

Creates a new APIError instance.

Properties

readonly
abstract
details: Record<string, unknown>

Additional details about the error, often used for debugging purposes.

readonly
abstract
error: string

An optional error identifier or code.

The HTTP status code associated with the error.

Static Properties

readonly
schema: z.ZodObject<{ message: z.ZodString; statusCode: z.ZodNumber; error: z.ZodOptional<z.ZodString>; details: z.ZodOptional<z.AnyZodObject>; }>

Static Methods

is(error: unknown): error is APIError

Validates whether an unknown value conforms to the APIError schema. This is more thorough than an instanceof check as it verifies all required properties and their types using the defined schema.

Add Package

deno add jsr:@temboplus/afloat

Import symbol

import { APIError } from "@temboplus/afloat";

---- OR ----

Import directly with a jsr specifier

import { APIError } from "jsr:@temboplus/afloat";

Add Package

npx jsr add @temboplus/afloat

Import symbol

import { APIError } from "@temboplus/afloat";

Add Package

yarn dlx jsr add @temboplus/afloat

Import symbol

import { APIError } from "@temboplus/afloat";

Add Package

pnpm dlx jsr add @temboplus/afloat

Import symbol

import { APIError } from "@temboplus/afloat";

Add Package

bunx jsr add @temboplus/afloat

Import symbol

import { APIError } from "@temboplus/afloat";