CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-backstage--errors

Common utilities for error handling within Backstage with structured error classes and serialization functions

63

1.28x
Overview
Eval results
Files

task.mdevals/scenario-2/

Error Shape Utilities

Helpers to validate and collect error-like values thrown from unknown sources.

Capabilities

Enforcing error shape

  • Returning a standard Error unchanged when given an Error with non-empty name and message @test
  • Creating a new Error that copies the provided name and message when given a plain object that already has those string fields @test
  • Throwing a TypeError that mentions "error" when given an object missing a non-empty message @test

Collecting errors from mixed inputs

  • From [new Error("boom"), { name: "RemoteFailure", message: "503" }, null, { message: "ignored" }, 7] returns two Error objects where the first is the original error and the second has name "RemoteFailure" and message "503" @test

Implementation

@generates

API

export function ensureError(value: unknown): Error;
/**
 * Normalizes an array of unknown values into real Error objects,
 * skipping any entries that are not error-like.
 */
export function collectErrors(values: unknown[]): Error[];

Dependencies { .dependencies }

@backstage/errors { .dependency }

Provides utilities for guarding and asserting error-shaped values when handling unknown failures. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-backstage--errors

tile.json