Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/libauth/src/lib/format/error.ts>formatError

An ultra-lightweight, zero-dependency JavaScript library for Bitcoin Cash, Bitcoin, and Bitauth applications.
Latest
variable formatError
import { formatError } from "https://deno.land/x/libauth@v2.0.0-alpha.9/src/lib/format/error.ts";

A simple method used throughout Libauth to format error messages. By formatting errors this way, downstream consumers can detect specific error types by matching the errorType. For example, the error:

formatError(SomeTypeOfError.exceedsMaximum, `Provided value: ${value}`);

Can be detected with String.includes(), even if the SomeTypeOfError.exceedsMaximum error message changes:

error.includes(SomeTypeOfError.exceedsMaximum);
// => true

Using this method ensures consistency across the library.

type

(errorType: string, errorDetails?: string) => unknown