error_detail.ts

Printing an error with what explains it: its message and its chain of causes.

A host module's error says only kind: target in its message, and what the OS or the module said of the failure is its cause, so code that shows a failure to a person prints the chain, as Gro's own reports do. Grants nothing and imports nothing, so any module, a package's included, prints errors with it.

view source

Declarations
#

3 declarations

format_error_causes
#

error_detail.ts view source

(error: unknown): string | null import {format_error_causes} from '@fuzdev/gro/error_detail.js';

The chain of causes beneath error, printed as format_error_detail prints them, without error's own message, for a report that has already shown it, such as a stack: ENOENT: no such file or directory, open '/p/a.txt'. null when there is no cause to print. Never throws.

error

any thrown value

type unknown

returns

string | null

format_error_detail
#

error_detail.ts view source

(error: unknown): string import {format_error_detail} from '@fuzdev/gro/error_detail.js';

The message of error followed by its causes', each in parentheses inside the one before: not_found: /p/a.txt (ENOENT: no such file or directory, open '/p/a.txt'). An Error's message and a string are printed; the chain ends at any other value, at a cause already printed, and past MAX_ERROR_CAUSES. A thrown value that isn't an Error prints as String prints a primitive, and an object as its type in brackets ([object]). Control and bidirectional formatting characters are written as \u{…} escapes, so text the error's maker chose prints as one line that can't move the cursor or reorder what a terminal shows. Never throws: a getter that throws, or a proxy, ends the chain there.

error

any thrown value, typically a host module's error

type unknown

returns

string

MAX_ERROR_CAUSES
#

error_detail.ts view source

8 import {MAX_ERROR_CAUSES} from '@fuzdev/gro/error_detail.js';

The most causes printed beneath an error; a longer chain ends with ….

Imported by
#