Common utilities for error handling within Backstage with structured error classes and serialization functions
63
Utilities for converting runtime errors into structured payloads for transport and restoring them back for local handling, while still producing readable strings for unknown error inputs.
includeStack is false. @testincludeStack is true, the payload includes non-empty stack strings for both an error and its nested cause. @test{ note: "boom" } yields a human-readable string that mentions the original value instead of a generic placeholder. @test@generates
export type ErrorPayload = {
name: string;
message: string;
stack?: string;
cause?: ErrorPayload;
[key: string]: unknown;
};
export type PayloadOptions = {
includeStack?: boolean;
};
export function toPayload(error: Error, options?: PayloadOptions): ErrorPayload;
export function fromPayload(payload: ErrorPayload): Error;
export function describeUnknown(value: unknown): string;Provides helpers to serialize and deserialize error objects and to stringify unknown errors for logging.
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