exception documentation
class HandlerError(Exception):
Constructor: HandlerError(message, type, retryable_override, stack_trace, original_failure)
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_override=True )
| Method | __init__ |
Initialize a new HandlerError. |
| Instance Variable | message |
Undocumented |
| Instance Variable | original |
Undocumented |
| Instance Variable | raw |
Undocumented |
| Instance Variable | retryable |
Undocumented |
| Instance Variable | stack |
Undocumented |
| Instance Variable | type |
Undocumented |
| Property | retryable |
Whether this error should be retried. |
def __init__(self, message:
str, *, type: HandlerErrorType | str, retryable_override: bool | None = None, stack_trace: str | None = None, original_failure: Failure | None = None):
¶
Initialize a new HandlerError.
| Parameters | |
message:str | A descriptive message for the error. |
type:HandlerErrorType | str | The HandlerErrorType of the error, or a
string representation of the error type. If a string is
provided and doesn't match a known error type, it will
be treated as UNKNOWN and a warning will be logged. |
retryablebool | None | Optionally set whether the error should be retried. By default, the error type is used to determine this. |
stackstr | None | An optional stack trace string. |
originalFailure | None | Set if this error is constructed from a failure object. |
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