exception documentation

class HandlerError(Exception):

Constructor: HandlerError(message, type, retryable_override)

View In Hierarchy

A Nexus handler error.

This exception is used to represent errors that occur during the handling of a Nexus operation that should be reported to the caller as a handler error.

Example

import nexusrpc

# Raise a bad request error
raise nexusrpc.HandlerError(
    "Invalid input provided",
    type=nexusrpc.HandlerErrorType.BAD_REQUEST
)

# Raise a retryable internal error
raise nexusrpc.HandlerError(
    "Database unavailable",
    type=nexusrpc.HandlerErrorType.INTERNAL,
    retryable=True
)
Method __init__ Initialize a new HandlerError.
Property retryable Whether this error should be retried.
Property retryable_override The optional retryability override set when this error was created.
Property type The type of handler error.
Instance Variable _retryable_override Undocumented
Instance Variable _type Undocumented
def __init__(self, message: str, *, type: HandlerErrorType, retryable_override: bool | None = None):

Initialize a new HandlerError.

Parameters
message:strA descriptive message for the error. This will become the message in the resulting Nexus Failure object.
type:HandlerErrorTypeThe HandlerErrorType of the error.
retryable_override:bool | NoneOptionally set whether the error should be retried. By default, the error type is used to determine this.
@property
retryable: bool =

Whether this error should be retried.

If retryable_override is None, then the default behavior for the error type is used. See https://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors

@property
retryable_override: bool | None =

The optional retryability override set when this error was created.

_retryable_override =

Undocumented

_type =

Undocumented