
Security News
TypeScript 6.0 Released: The Final JavaScript-Based Version
TypeScript 6.0 introduces new standard APIs, modern default settings, and deprecations as it prepares projects for the upcoming TypeScript 7.0 release.
@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 215 weekly downloads. As such, @xylabs/error popularity was classified as not 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
TypeScript 6.0 introduces new standard APIs, modern default settings, and deprecations as it prepares projects for the upcoming TypeScript 7.0 release.

Security News
/Research
Newly published Trivy Docker images (0.69.4, 0.69.5, and 0.69.6) were found to contain infostealer IOCs and were pushed to Docker Hub without corresponding GitHub releases.

Research
/Security News
The worm-enabled campaign hit @emilgroup and @teale.io, then used an ICP canister to deliver follow-on payloads.