Skip to content

Error

Error is raised for system and I/O failures.

It can be subclassed for library-specific operational failures.

Inherits from: std.RuntimeError

Constructor

Error message …

Creates a system error.

Parameters

NameTypeDescription
message Str Error message.
:code? ErrorCode Underlying platform code.

Example

let error = Error "operation failed" code: $sys.linux.Errno.EIO
try
  fs.read "/definitely/missing"
catch Error: err
  echo $Str(err)

str(err) returns the underlying system error message and appends the native symbolic code in parentheses when it is known.

Fields

code @ (ErrorCode | nil)

The underlying native system error code, or nil when one does not exist.

The value is sys.linux.Errno, sys.freebsd.Errno, sys.macos.Errno, or sys.windows.WinError, according to the system where the error originated.