errors
Common errors.
Install
npm install --save @blackglory/errors
yarn add @blackglory/errors
API
Interfaces
type CustomErrorConstructor<T extends CustomError = CustomError> = new (message?: string) => T
interface SerializableError {
name: string
message: string
stack: string | null
}
CustomError
class CustomError extends Error {}
ExpectedError
class ExpectedError extends CustomError {}
AssertionError
class AssertionError extends CustomError {}
normalize
function normalize(err: Error): SerializableError
assert
function assert(condition: unknown, message?: string): asserts condition
refute
function refute(condition: unknown, message?: string): void
A negative assertion, expects the condition to be falsy.