Jaspers Hub

jaspers / research

pluginOfficialReviewed★ 0↓ 28

Jaspers Research: Research rooms where configurable analysts research companies in parallel over SEC filings data, answering with checked citations.

625 B
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
5export 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}