Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879/** System error narrowing shared by settings loading and output spooling.
@module */
//region Types
/** Error carrying a Node system code, which is how missing files are distinguished from permission or device faults without matching message text. @example ```ts const error: ErrorWithCode = Object.assign(new Error('gone'), { code: 'ENOENT', },); ``` */type ErrorWithCode = Error & { /** Node system code such as `ENOENT`. */ readonly code: unknown;};
//endregion Types
//region Guards
/** Narrows a caught value to an error carrying a system code. @param error - caught value from a filesystem call @returns whether a system code is readable @example ```ts isErrorWithCode(new Error('plain')); ``` */function isErrorWithCode(error: unknown, ): error is ErrorWithCode { return (Error.isError(error,)) && ('code' in error);}
/** Reports whether a caught value means the file simply is not there. @param error - caught value from a filesystem call @returns whether absence explains the failure @example ```ts isMissingFileCode(error, 'ENOENT'); ``` */function isMissingFileCode( { error, code, }: { readonly error: unknown; readonly code: string; },): boolean { return isErrorWithCode(error, ) && (error.code === code);}
//endregion Guards
export { isErrorWithCode, isMissingFileCode,};
export type { ErrorWithCode, };