Skip to content

Errors#

lit.sdk.errors #

This module defines custom exception classes for various types of errors in the Lit system. It also provides a decorator function for handling these errors in a consistent manner.

LitDataError #

Bases: LitError

A custom exception class for Lit data errors.

__init__(*args, code=None) #

Initializes a new instance of LitDataError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

LitDeviceError #

Bases: LitError

A custom exception class for Lit device errors.

__init__(*args, code=None) #

Initializes a new instance of LitDeviceError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

LitError #

Bases: Exception

A custom exception class for Lit errors.

code = code instance-attribute #

The error code, or None if not specified.

__init__(*args, code=None) #

Initializes a new instance of LitError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

__str__() #

Returns a string representation of the error.

If no error code is specified, returns the base class's string representation. Otherwise, returns an error message with the specified code.

Returns:

Name Type Description
str str

The string representation of the error.

LitModelError #

Bases: LitError

A custom exception class for Lit model errors.

__init__(*args, code=None) #

Initializes a new instance of LitModelError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

LitServiceError #

Bases: LitError

A custom exception class for Lit service errors.

__init__(*args, code=None) #

Initializes a new instance of LitServiceError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

LitVaultError #

Bases: LitError

A custom exception class for Lit vault errors.

__init__(*args, code=None) #

Initializes a new instance of LitVaultError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

()
code int | None

The error code. Defaults to None.

None

lit_error_handler(error_type=LitError) #

A decorator function that catches and re-raises exceptions with a custom error type.

Parameters:

Name Type Description Default
error_type Type[LitError]

The type of exception to raise. Defaults to LitError.

LitError

Returns:

Type Description
Callable

A wrapper function that catches exceptions and raises the specified error type.

Examples:

>>> @lit_error_handler()
... def raises_error():
...     assert False
...
>>> raises_error()
Traceback (most recent call last):
File "/opt/lit/src/lit/sdk/errors.py", line 130, in wrapper
File "<stdin>", line 3, in raises_error
AssertionError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/lit/src/lit/sdk/errors.py", line 132, in wrapper
lit.sdk.errors.LitError: An error occurred in function 'raises_error'