MCPcopy Create free account
hub / github.com/decentpaste/decentpaste / getErrorMessage

Function getErrorMessage

decentpaste-app/src/utils/error.ts:7–18  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

5 * Handles Error objects, strings, and unknown error types.
6 */
7export function getErrorMessage(error: unknown): string {
8 if (error instanceof Error) {
9 return error.message;
10 }
11 if (typeof error === 'string') {
12 return error;
13 }
14 if (error && typeof error === 'object' && 'message' in error) {
15 return String((error as { message: unknown }).message);
16 }
17 return 'An unexpected error occurred';
18}
19
20/**
21 * Type guard to check if an error is an AbortError (e.g., from cancelled operations)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected