SystemErrorError data for a platform or system operation failure.
When to use
Use when you need normalized reason data for a platform or system operation failure, including the operation details.
Details
The error records a normalized _tag, the module and method that failed,
and optional details such as the syscall, path or descriptor, description,
and original cause. It is usually wrapped in PlatformError.
export class class SystemErrorclass SystemError {
message: string;
name: string;
stack: string;
cause: unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
_tag: SystemErrorTag;
module: string;
method: string;
description: string | undefined;
syscall: string | undefined;
pathOrDescriptor: string | number | undefined;
}
Error data for a platform or system operation failure.
When to use
Use when you need normalized reason data for a platform or system operation
failure, including the operation details.
Details
The error records a normalized _tag, the module and method that failed,
and optional details such as the syscall, path or descriptor, description,
and original cause. It is usually wrapped in PlatformError.
SystemError extends import DataData.Error<{
_tag: SystemErrorTag_tag: type SystemErrorTag =
| "AlreadyExists"
| "BadResource"
| "Busy"
| "InvalidData"
| "NotFound"
| "PermissionDenied"
| "TimedOut"
| "UnexpectedEof"
| "Unknown"
| "WouldBlock"
| "WriteZero"
Normalized category for failures reported by platform or system operations.
When to use
Use to type or match the normalized _tag on SystemError values reported
by platform operations.
Details
The tags group lower-level platform errors into a stable set such as
NotFound, PermissionDenied, TimedOut, and Unknown.
SystemErrorTag
module: stringmodule: string
method: stringmethod: string
description?: string | undefineddescription?: string | undefined
syscall?: string | undefinedsyscall?: string | undefined
pathOrDescriptor?: string | number | undefinedpathOrDescriptor?: string | number | undefined
cause?: unknowncause?: unknown
}> {
/**
* Formats the normalized system error tag with operation and path details.
*
* **When to use**
*
* Use to read the formatted error message for a normalized system failure.
*
* @since 4.0.0
*/
override get SystemError.message: stringFormats the normalized system error tag with operation and path details.
When to use
Use to read the formatted error message for a normalized system failure.
message(): string {
return `${this._tag}: ${this.module}.${this.method}${
this.pathOrDescriptor !== var undefinedundefined ? ` (${this.pathOrDescriptor})` : ""
}${this.description ? `: ${this.description}` : ""}`
}
}