@threadplane/chatFunctionv0.3.4

extractErrorMessage

Coerce an unknown error value into a human-readable message string — reads .message from Errors, returns strings as-is, and String()-casts the rest. Useful when rendering an agent's error outside the built-in chat-error component.

import { extractErrorMessage } from '@threadplane/chat';

Declaration · overload 1

export declare function extractErrorMessage(error: unknown): string | null;

Parameters

error · required
unknown

Any caught/agent error value.

Returns

string | null

The message text, or null when error is nullish.

Examples

const msg = extractErrorMessage(agent.error());