Errors#

All UNIT errors inherit from Error and also from the most appropriate Python built-in exception, so standard except clauses work naturally.

try:
    proc.divide()
except ValueError as e:
    # catches unit.InvalidUsage (which inherits ValueError)
    print(e)

try:
    proc.compile()
except unit.Error as e:
    # catches any UNIT error
    print(e)
class unit.Error#

Base class for all UNIT errors. Inherits from the internal C extension error type.

message: str#

The error message from the C library.

class unit.NoMemory#

Raised when memory allocation fails. Inherits from both Error and MemoryError.

class unit.InvalidUsage#

Raised when the API is used incorrectly, such as dividing by zero during constant folding, or emitting instructions in an invalid order. Inherits from both Error and ValueError.

class unit.OSFailure#

Raised when an operating system call fails, such as mmap during JIT compilation. Inherits from both Error and OSError.

class unit.UnsupportedPlatform#

Raised when compiling for a platform that UNIT does not support. Inherits from Error.

class unit.ErrorCode#

Enum of error codes from the C library. Primarily for internal use.

UNIT_ERROR_NONE#
UNIT_ERROR_NO_MEMORY#
UNIT_ERROR_INVALID_USAGE#
UNIT_ERROR_OS_FAILURE#
UNIT_ERROR_UNSUPPORTED_PLATFORM#