You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@xylabs/error

Package Overview
Dependencies
Maintainers
5
Versions
417
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/error

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

latest
Source
npmnpm
Version
5.0.86
Version published
Weekly downloads
13K
1138.81%
Maintainers
5
Weekly downloads
 
Created
Source

@xylabs/error

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Reference

@xylabs/error

Type Aliases

Type AliasDescription
AssertConfigConfiguration for assertion behavior: a static message string, a boolean toggle, or a callback.

Functions

FunctionDescription
assertErrorThrows an Error based on the assert configuration when a value fails validation.
handleErrorInvokes the handler if the value is an Error, otherwise re-throws it.
handleErrorAsyncAsync version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it.
isErrorType guard that checks whether a value is an Error instance.

functions

assertError

@xylabs/error

function assertError(
   value: unknown, 
   assert: AssertConfig | undefined, 
   defaultMessage: string): undefined;

Throws an Error based on the assert configuration when a value fails validation.

Parameters

ParameterTypeDescription
valueunknownThe value being validated
assertAssertConfig | undefinedAssertion config controlling the error message
defaultMessagestringFallback message if no custom message is provided

Returns

undefined

handleError

@xylabs/error

function handleError<T>(error: any, handler: (error: Error) => T): T;

Invokes the handler if the value is an Error, otherwise re-throws it.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
erroranyThe caught value to inspect
handler(error: Error) => TCallback invoked with the Error if it is one

Returns

T

The handler's return value

handleErrorAsync

@xylabs/error

function handleErrorAsync<T>(error: any, handler: (error: Error) => Promise<T>): Promise<T>;

Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
erroranyThe caught value to inspect
handler(error: Error) => Promise<T>Async callback invoked with the Error if it is one

Returns

Promise<T>

The handler's resolved return value

isError

@xylabs/error

Call Signature

function isError(value: unknown): value is Error;

Type guard that checks whether a value is an Error instance.

Parameters

ParameterType
valueunknown

Returns

value is Error

Call Signature

function isError<T>(value: T): value is Extract<T, Error>;

Type guard that checks whether a value is an Error instance.

Type Parameters

Type Parameter
T

Parameters

ParameterType
valueT

Returns

value is Extract<T, Error>

type-aliases

AssertConfig

@xylabs/error

type AssertConfig = string | AssertCallback | boolean;

Configuration for assertion behavior: a static message string, a boolean toggle, or a callback.

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs

Keywords

error

FAQs

Package last updated on 11 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts