
Security News
TC39 Advances Temporal to Stage 4 Alongside Several ECMAScript Proposals
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.
@xylabs/error
Advanced tools
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
@xylabs/error
| Type Alias | Description |
|---|---|
| AssertConfig | Configuration for assertion behavior: a static message string, a boolean toggle, or a callback. |
| Function | Description |
|---|---|
| assertError | Throws an Error based on the assert configuration when a value fails validation. |
| handleError | Invokes the handler if the value is an Error, otherwise re-throws it. |
| handleErrorAsync | Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it. |
| isError | Type guard that checks whether a value is an Error instance. |
function assertError(
value: unknown,
assert: AssertConfig | undefined,
defaultMessage: string): undefined;
Throws an Error based on the assert configuration when a value fails validation.
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value being validated |
assert | AssertConfig | undefined | Assertion config controlling the error message |
defaultMessage | string | Fallback message if no custom message is provided |
undefined
function handleError<T>(error: any, handler: (error: Error) => T): T;
Invokes the handler if the value is an Error, otherwise re-throws it.
| Type Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
error | any | The caught value to inspect |
handler | (error: Error) => T | Callback invoked with the Error if it is one |
T
The handler's return value
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 Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
error | any | The caught value to inspect |
handler | (error: Error) => Promise<T> | Async callback invoked with the Error if it is one |
Promise<T>
The handler's resolved return value
function isError(value: unknown): value is Error;
Type guard that checks whether a value is an Error instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Error
function isError<T>(value: T): value is Extract<T, Error>;
Type guard that checks whether a value is an Error instance.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Error>
type AssertConfig = string | AssertCallback | boolean;
Configuration for assertion behavior: a static message string, a boolean toggle, or a callback.
Part of sdk-js
See the LICENSE file for license details
FAQs
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
The npm package @xylabs/error receives a total of 2,285 weekly downloads. As such, @xylabs/error popularity was classified as popular.
We found that @xylabs/error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

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.

Security News
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.

Research
/Security News
Since January 31, 2026, we identified at least 72 additional malicious Open VSX extensions, including transitive GlassWorm loader extensions targeting developers.

Research
Six malicious Packagist packages posing as OphimCMS themes contain trojanized jQuery that exfiltrates URLs, injects ads, and loads FUNNULL-linked redirects.