UNPKG

verror-0

Version:

VError without dependencies on top of nodejs standart library

13 lines (12 loc) 320 B
import { cause } from './cause.js'; import { isError } from './is-error.js'; export const stack = (err) => { if (!isError(err)) { throw new Error('err must be an Error'); } const c = cause(err); if (c) { return err.stack + '\ncaused by: ' + stack(c); } return err.stack ?? ''; };