isErrno(value: unknown,...codes: string[]): value is ErrnoError
Whether value is an Error carrying one of the given Node code strings — ENOENT,
EADDRINUSE, EBUSY. With no codes it matches any error that has a string code at all
(which includes Node's ERR_* internal errors, e.g. ERR_MODULE_NOT_FOUND).
This is the guard for the flat classification line that follows a Result.try on Node
API calls — the discrimination the codebase used to perform as an err.code !== 'X' && throw err ladder in seven places:
import fs from 'node:fs/promises'; import * as Result from './index.ts'; // Defined, not invoked: the rethrow line is the point, and a sandboxed doctest run // would trip it with a permission error rather than the declared EEXIST. async function publish(tmpPath: string, lockPath: string) { const linked = await Result.try(fs.link, tmpPath, lockPath); if (!linked.ok && !Result.isErrno(linked.error, 'EEXIST')) throw linked.error; return linked.ok; }
value is ErrnoError