Common utilities for error handling within Backstage with structured error classes and serialization functions
63
Utilities that wrap upstream failures with consistent messages, filter causes to real errors, and allow transport-safe serialization.
new Error("db offline") yields an error whose message becomes Gateway timeout: db offline while retaining the provided error as its cause. @testGateway timeout: oops but whose cause property is unset. @testname remains "ThirdPartyError", whose message becomes catalog request failed: service down, and whose cause remains the original upstream error. @test42) throws an informative exception mentioning the received value. @testname, message, and nested cause fields but omitting stacks by default. @teststack fields in the serialized object. @testError whose name, message, and nested cause match the original structure. @test@generates
export interface SerializedErrorPayload {
name: string;
message: string;
stack?: string;
cause?: SerializedErrorPayload;
}
export function createServiceError(message: string, cause?: unknown): Error;
export function forwardUpstreamError(context: string, upstream: unknown): Error;
export function serializeForTransport(error: unknown, includeStack?: boolean): SerializedErrorPayload;
export function deserializeFromTransport(payload: SerializedErrorPayload): Error;Error utilities for wrapping, forwarding, and serializing errors. @satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-backstage--errorsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10