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.

Note

This module is unrelated to the implementation of error handling in Chapel generally, and is being maintained for legacy reasons.

proc ioerror(error: syserr, msg: string)

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)

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))

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))

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