2026-01-13 17:23:28 +01:00

8 lines
255 B
TypeScript

export function getErrnoCode(error: unknown): string | undefined {
if (typeof error !== 'object' || error === null) {
return undefined
}
const rec = error as Record<string, unknown>
return typeof rec.code === 'string' ? rec.code : undefined
}