Package Exports
- @blackglory/errors
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@blackglory/errors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
errors
Common errors.
Install
npm install --save @blackglory/errors
# or
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
/**
* @throws {AssertionError}
*/
function assert(condition: unknown, message?: string): asserts condition
refute
/**
* @throws {ExpectedError}
*/
function refute(condition: unknown, message?: string): void
A negative assertion, expects the condition to be falsy.