Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859/** Caught-value text preserving diagnostic information and exposing possible caller-defined conversion effects. @example ```ts import { caughtValueText, } from '@monochromatic-dev/module-caught-value'; caughtValueText(new Error('offline')); // 'offline' caughtValueText({ toString: () => 'details' }); // 'details' ``` @packageDocumentation */
/** Formats a caught value without discarding its diagnostic text. Error values contribute their message. Every other value follows JavaScript string conversion so thrown objects can provide their own diagnostic text. @param value - Caught value to render. @returns Error message or string-coerced thrown value. @mutates value - Reading an Error message or string conversion may invoke getters, proxy traps, `Symbol.toPrimitive`, `toString`, or `valueOf`. @example ```ts caughtValueText(new Error('offline')); // 'offline' caughtValueText(404); // '404' ``` */export function caughtValueText(value: unknown,): string { if (Error.isError(value,)) return value.message; return String(value,);}
/** Formats a caught value with Error stack detail when available. @param value - Caught value to render. @returns Error stack, Error message, or string-coerced thrown value. @mutates value - Reading Error fields or string conversion may invoke getters, proxy traps, `Symbol.toPrimitive`, `toString`, or `valueOf`. @example ```ts caughtValueStack(new Error('offline')); // stack containing "offline" ``` */export function caughtValueStack(value: unknown,): string { if (Error.isError(value,)) return value.stack ?? value.message; return String(value,);}