Skip to content

Exceptions

siapy.core.exceptions

SiapyError

SiapyError(message: str, name: str = 'SiaPy')

Bases: Exception

Base exception for SiaPy library.

PARAMETER DESCRIPTION
message

TYPE: str

name

TYPE: str DEFAULT: 'SiaPy'

Source code in siapy/core/exceptions.py
18
19
20
21
def __init__(self, message: str, name: str = "SiaPy") -> None:
    self.message: str = message
    self.name: str = name
    super().__init__(self.message, self.name)

message instance-attribute

message: str = message

name instance-attribute

name: str = name

InvalidFilepathError

InvalidFilepathError(filename: str)

Bases: SiapyError

Exception raised when a required file is not found.

PARAMETER DESCRIPTION
filename

TYPE: str

Source code in siapy/core/exceptions.py
27
28
29
def __init__(self, filename: str) -> None:
    self.filename: str = filename
    super().__init__(f"File not found: {filename}")

message instance-attribute

message: str = message

name instance-attribute

name: str = name

filename instance-attribute

filename: str = filename

InvalidInputError

InvalidInputError(input_value: Any, message: str = 'Invalid input')

Bases: SiapyError

Exception raised for invalid input.

PARAMETER DESCRIPTION
input_value

TYPE: Any

message

TYPE: str DEFAULT: 'Invalid input'

Source code in siapy/core/exceptions.py
35
36
37
38
def __init__(self, input_value: Any, message: str = "Invalid input") -> None:
    self.input_value: Any = input_value
    self.message: str = message
    super().__init__(f"{message}: {input_value}")

name instance-attribute

name: str = name

input_value instance-attribute

input_value: Any = input_value

message instance-attribute

message: str = message

InvalidTypeError

InvalidTypeError(input_value: Any, allowed_types: type | tuple[type, ...], message: str = 'Invalid type')

Bases: SiapyError

Exception raised for invalid type.

PARAMETER DESCRIPTION
input_value

TYPE: Any

allowed_types

TYPE: type | tuple[type, ...]

message

TYPE: str DEFAULT: 'Invalid type'

Source code in siapy/core/exceptions.py
44
45
46
47
48
49
50
51
52
53
54
55
56
def __init__(
    self,
    input_value: Any,
    allowed_types: type | tuple[type, ...],
    message: str = "Invalid type",
) -> None:
    self.input_value: Any = input_value
    self.input_type: Any = type(input_value)
    self.allowed_types: type | tuple[type, ...] = allowed_types
    self.message: str = message
    super().__init__(
        f"{message}: {input_value} (type: {self.input_type}). Allowed types: {allowed_types}"
    )

name instance-attribute

name: str = name

input_value instance-attribute

input_value: Any = input_value

input_type instance-attribute

input_type: Any = type(input_value)

allowed_types instance-attribute

allowed_types: type | tuple[type, ...] = allowed_types

message instance-attribute

message: str = message

ProcessingError

ProcessingError(message: str = 'An error occurred during processing')

Bases: SiapyError

Exception raised for errors during processing.

PARAMETER DESCRIPTION
message

TYPE: str DEFAULT: 'An error occurred during processing'

Source code in siapy/core/exceptions.py
62
63
64
def __init__(self, message: str = "An error occurred during processing") -> None:
    self.message: str = message
    super().__init__(message)

name instance-attribute

name: str = name

message instance-attribute

message: str = message

ConfigurationError

ConfigurationError(message: str = 'Configuration error')

Bases: SiapyError

Exception raised for configuration errors.

PARAMETER DESCRIPTION
message

TYPE: str DEFAULT: 'Configuration error'

Source code in siapy/core/exceptions.py
70
71
72
def __init__(self, message: str = "Configuration error") -> None:
    self.message: str = message
    super().__init__(message)

name instance-attribute

name: str = name

message instance-attribute

message: str = message

MethodNotImplementedError

MethodNotImplementedError(class_name: str, method_name: str)

Bases: SiapyError

Exception raised for not implemented methods.

PARAMETER DESCRIPTION
class_name

TYPE: str

method_name

TYPE: str

Source code in siapy/core/exceptions.py
78
79
80
81
82
83
def __init__(self, class_name: str, method_name: str) -> None:
    self.class_name: str = class_name
    self.method_name: str = method_name
    super().__init__(
        f"Method '{method_name}' not implemented in class '{class_name}'"
    )

message instance-attribute

message: str = message

name instance-attribute

name: str = name

class_name instance-attribute

class_name: str = class_name

method_name instance-attribute

method_name: str = method_name

DirectInitializationError

DirectInitializationError(class_: type)

Bases: SiapyError

Exception raised when a class method is required to create an instance.

PARAMETER DESCRIPTION
class_

TYPE: type

Source code in siapy/core/exceptions.py
89
90
91
92
93
94
95
96
def __init__(self, class_: type) -> None:
    from siapy.utils.general import get_classmethods

    self.class_name: str = class_.__class__.__name__
    self.class_methods: list[str] = get_classmethods(class_)
    super().__init__(
        f"Use any of the @classmethod to create a new instance of '{self.class_name}': {self.class_methods}"
    )

message instance-attribute

message: str = message

name instance-attribute

name: str = name

class_name instance-attribute

class_name: str = __name__

class_methods instance-attribute

class_methods: list[str] = get_classmethods(class_)