SysError¶
Usage
use SysError;
This module helps handle system errors.
This module defines the type syserr
, which can encode an error code or
error message and be returned from routines generating an error. Additional
routines are provided to print a useful error message from a syserr
.
The IO module uses these routines in a way that supports error inspection and rapid prototyping. Most routines in the IO module have two forms. In one form, an error (of type syserr) is returned in an out error argument. In the second form, no error is returned, and instead the task will halt with a fatal error if an error is encountered.
-
class
SystemError
: Error¶ SystemError
is a base class forErrors
generated fromsyserr
. It provides factory methods to create different subtypes based on thesyserr
that is passed.-
var
err
: syserr¶
-
var
details
: string¶
-
proc
SystemError
(err: syserr, details: string = "")¶
-
proc
message
()¶ Provides a formatted string output for
SystemError
, generated from the internalerr
and thedetails
string.
-
proc
writeThis
(f)¶
-
proc type
fromSyserr
(err: syserr, details: string = "")¶ Return the matching
SystemError
subtype for a givensyserr
, with an optional string containing extra details.Arguments: - err -- the syserr to generate from
- details -- extra information to include with the error
-
proc type
fromSyserr
(err: int, details: string = "") Return the matching
SystemError
subtype for a given error number, with an optional string containing extra details.Arguments: - err -- the number to generate from
- details -- extra information to include with the error
-
var
-
class
BlockingIOError
: SystemError¶ BlockingIOError
is the subclass ofSystemError
corresponding toSysBasic.EAGAIN
,SysBasic.EALREADY
,SysBasic.EWOULDBLOCK
, andSysBasic.EINPROGRESS
.-
proc
BlockingIOError
(details: string = "", err: syserr = EWOULDBLOCK)¶
-
proc
-
class
ChildProcessError
: SystemError¶ ChildProcessError
is the subclass ofSystemError
corresponding toSysBasic.ECHILD
.-
proc
ChildProcessError
(details: string = "", err: syserr = ECHILD)¶
-
proc
-
class
ConnectionError
: SystemError¶ ConnectionError
is the subclass ofSystemError
that serves as the base class for all system errors regarding connections.
-
class
BrokenPipeError
: ConnectionError¶ BrokenPipeError
is the subclass ofConnectionError
corresponding toSysBasic.EPIPE
andSysBasic.ESHUTDOWN
.-
proc
BrokenPipeError
(details: string = "", err: syserr = EPIPE)¶
-
proc
-
class
ConnectionAbortedError
: ConnectionError¶ ConnectionAbortedError
is the subclass ofConnectionError
corresponding toSysBasic.ECONNABORTED
.-
proc
ConnectionAbortedError
(details: string = "", err: syserr = ECONNABORTED)¶
-
proc
-
class
ConnectionRefusedError
: ConnectionError¶ ConnectionRefusedError
is the subclass ofConnectionError
corresponding toSysBasic.ECONNREFUSED
.-
proc
ConnectionRefusedError
(details: string = "", err: syserr = ECONNREFUSED)¶
-
proc
-
class
ConnectionResetError
: ConnectionError¶ ConnectionResetError
is the subclass ofConnectionError
corresponding toSysBasic.ECONNRESET
.-
proc
ConnectionResetError
(details: string = "", err: syserr = ECONNRESET)¶
-
proc
-
class
FileExistsError
: SystemError¶ FileExistsError
is the subclass ofSystemError
corresponding toSysBasic.EEXIST
.-
proc
FileExistsError
(details: string = "", err: syserr = EEXIST)¶
-
proc
-
class
FileNotFoundError
: SystemError¶ FileNotFoundError
is the subclass ofSystemError
corresponding toSysBasic.ENOENT
.-
proc
FileNotFoundError
(details: string = "", err: syserr = ENOENT)¶
-
proc
-
class
InterruptedError
: SystemError¶ InterruptedError
is the subclass ofSystemError
corresponding toSysBasic.EINTR
.-
proc
InterruptedError
(details: string = "", err: syserr = EINTR)¶
-
proc
-
class
IsADirectoryError
: SystemError¶ IsADirectoryError
is the subclass ofSystemError
corresponding toSysBasic.EISDIR
.-
proc
IsADirectoryError
(details: string = "", err: syserr = EISDIR)¶
-
proc
-
class
NotADirectoryError
: SystemError¶ NotADirectoryError
is the subclass ofSystemError
corresponding toSysBasic.ENOTDIR
.-
proc
NotADirectoryError
(details: string = "", err: syserr = ENOTDIR)¶
-
proc
-
class
PermissionError
: SystemError¶ PermissionError
is the subclass ofSystemError
corresponding toSysBasic.EACCES
andSysBasic.EPERM
.-
proc
PermissionError
(details: string = "", err: syserr = EPERM)¶
-
proc
-
class
ProcessLookupError
: SystemError¶ ProcessLookupError
is the subclass ofSystemError
corresponding toSysBasic.ESRCH
.-
proc
ProcessLookupError
(details: string = "", err: syserr = ESRCH)¶
-
proc
-
class
TimeoutError
: SystemError¶ TimeoutError
is the subclass ofSystemError
corresponding toSysBasic.ETIMEDOUT
.-
proc
TimeoutError
(details: string = "", err: syserr = ETIMEDOUT)¶
-
proc
-
class
IOError
: SystemError¶ IOError
is the subclass ofSystemError
that serves as the base class for all errors regarding inputs and their formatting. They are typically not directly generated by the OS, but they are used and emitted by the IO module.
-
class
EOFError
: IOError¶ EOFError
is the subclass ofSystemError
corresponding toSysBasic.EEOF
.-
proc
EOFError
(details: string = "", err: syserr = EEOF)¶
-
proc
-
class
UnexpectedEOFError
: IOError¶ UnexpectedEOFError
is the subclass ofSystemError
corresponding toSysBasic.ESHORT
.-
proc
UnexpectedEOFError
(details: string = "", err: syserr = ESHORT)¶
-
proc
-
class
BadFormatError
: IOError¶ BadFormatError
is the subclass ofSystemError
corresponding toSysBasic.EFORMAT
.-
proc
BadFormatError
(details: string = "", err: syserr = EFORMAT)¶
-
proc
-
proc
ioerror
(error: syserr, msg: string) throws¶ Halt with a useful message if there was an error. Do nothing if the error argument does not indicate an error occurred. The error message printed when halting will describe the error passed and msg will be appended to it.
Arguments: - error -- the error object
- msg -- extra information to print after the error description
-
proc
ioerror
(error: syserr, msg: string, path: string) throws Halt with a useful message if there was an error. Do nothing if the error argument does not indicate an error occurred. The error message printed when halting will describe the error passed and msg will be appended to it, along with the path related to the error (for example, the path to a file which could not be opened).
Arguments: - error -- the error object
- msg -- extra information to print after the error description
- path -- a path to print out that is related to the error
-
proc
ioerror
(error: syserr, msg: string, path: string, offset: int(64)) throws Halt with a useful message if there was an error. Do nothing if the error argument does not indicate an error occurred. The error message printed when halting will describe the error passed and msg will be appended to it, along with the path and file offset related to the error. For example, this routine might indicate a file format error at a particular location.
Arguments: - error -- the error object
- msg -- extra information to print after the error description
- path -- a path to print out that is related to the error
- offset -- an offset to print out that is related to the error
-
proc
ioerror
(errstr: string, msg: string, path: string, offset: int(64)) throws Halt with a useful message. Instead of an error argument, this routine takes in an error string to report. The error message printed when halting will describe the error passed and msg will be appended to it, along with the path and file offset related to the error. For example, this routine might indicate a file format error at a particular location.
This routine .
Arguments: - errstr -- the error string
- msg -- extra information to print after the error description
- path -- a path to print out that is related to the error
- offset -- an offset to print out that is related to the error
-
proc
errorToString
(error: syserr): string¶ Convert a syserr error code to a human-readable string describing that error.
Arguments: errstr -- the error string Returns: a string describing the error