Jaspers Research: Research rooms where configurable analysts research companies in parallel over SEC filings data, answering with checked citations.
| 1 | // An error's words, whichever realm made it. This plugin's code runs in its own vm, so an Error the |
| 2 | // app creates (an abort's reason, a rejected call) is not `instanceof Error` here, and String() of it |
| 3 | // would lose its message or put "Error: " in front. |
| 4 | |
| 5 | export function errorText(value: unknown, fallback = 'stopped'): string { |
| 6 | if (typeof value === 'string') return value |
| 7 | if (typeof value === 'object' && value !== null && typeof (value as { message?: unknown }).message === 'string') { |
| 8 | return (value as { message: string }).message |
| 9 | } |
| 10 | return value === undefined || value === null ? fallback : String(value) |
| 11 | } |