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

Source
npmnpm
Version
5.0.84
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

  • AssertConfig

Functions

functions

assertError

@xylabs/error

function assertError(
   value, 
   assert, 
   defaultMessage): undefined;

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

Parameters

value

unknown

The value being validated

assert

Assertion config controlling the error message

AssertConfig | undefined

defaultMessage

string

Fallback message if no custom message is provided

Returns

undefined

handleError

@xylabs/error

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

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

Type Parameters

T

T

Parameters

error

any

The caught value to inspect

handler

(error) => T

Callback invoked with the Error if it is one

Returns

T

The handler's return value

handleErrorAsync

@xylabs/error

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

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

Type Parameters

T

T

Parameters

error

any

The caught value to inspect

handler

(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): value is Error;

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

Parameters

value

unknown

Returns

value is Error

Call Signature

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

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

Type Parameters

T

T

Parameters

value

T

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 10 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