rootCause(error: unknown): unknown
The deepest cause in the chain — the original failure, whatever wrapped it since.
import * as Failure from './failure.ts'; const FileMissing = Failure.define('FileMissing', (d: { path: string }) => `no such file: ${d.path}`); const root = new Error('EACCES'); const wrapped = FileMissing({ path: 'a.ts' }, { cause: root }); Failure.rootCause(wrapped) === root; // true, however many layers wrapped it on the way up