Skip to content

errorToString

Converts an error to a string representation, including nested causes and the aggregated errors of an AggregateError, with indentation.

Never throws: if the error cannot be formatted (a throwing getter, a malformed nested error), it falls back to the error’s own string and stack, so the error being reported is never hidden behind a failure to report it.

Import:

import { errorToString } from '@mnaoumov/typescript-lib/error';

Signature:

function errorToString(error: unknown): string

Parameters:

Parameter Type Description
error unknown The error to convert to a string.

Returns: string — The string representation of the error.