2Exception classes for PyHelios library.
4This module provides a hierarchy of exceptions that map to various error conditions
5in the Helios C++ core and PyHelios wrapper layer.
10 """Base exception class for all PyHelios-related errors."""
16 Runtime errors from Helios operations.
18 Raised when the Helios core encounters a runtime error condition,
19 such as invalid geometry parameters or numerical precision issues.
26 Invalid argument errors.
28 Raised when function parameters are invalid, such as null pointers,
29 out-of-range values, or incompatible data types.
36 UUID not found errors.
38 Raised when attempting to access a primitive or object that doesn't
39 exist in the Context using an invalid UUID.
46 File I/O related errors.
48 Raised when file operations fail, such as loading PLY files,
49 reading textures, or accessing plugin data files.
56 Memory allocation errors.
58 Raised when memory allocation fails, typically during large
59 geometry operations or texture loading.
66 GPU initialization errors.
68 Raised when GPU-related operations fail, such as OptiX initialization
69 for radiation modeling or CUDA setup.
76 Plugin not available errors.
78 Raised when attempting to use a plugin that is not compiled or
79 available in the current PyHelios installation.
88 Raised when an unexpected C++ exception occurs that doesn't
89 map to a specific error category.
95ERROR_CODE_TO_EXCEPTION = {
96 1: HeliosInvalidArgumentError,
97 2: HeliosUUIDNotFoundError,
99 4: HeliosMemoryAllocationError,
100 5: HeliosGPUInitializationError,
101 6: HeliosPluginNotAvailableError,
102 7: HeliosRuntimeError,
103 99: HeliosUnknownError,
109 Create an appropriate exception instance from an error code and message.
112 error_code (int): Error code from the C++ wrapper
113 error_message (str): Error message from the C++ wrapper
116 HeliosError: Appropriate exception instance
118 exception_class = ERROR_CODE_TO_EXCEPTION.get(error_code, HeliosUnknownError)
119 return exception_class(f
"Helios error {error_code}: {error_message}")
124 Check for Helios errors and raise appropriate Python exceptions.
126 This function is designed to be used as an errcheck callback for ctypes
130 get_error_func: Function to get the last error code
131 get_message_func: Function to get the last error message
134 HeliosError: If an error is detected
136 error_code = get_error_func()
138 error_message = get_message_func().decode(
'utf-8')
if get_message_func()
else "Unknown error"
Exception classes for PyHelios library.
GPU initialization errors.
Memory allocation errors.
Plugin not available errors.
Runtime errors from Helios operations.
check_helios_error(get_error_func, get_message_func)
Check for Helios errors and raise appropriate Python exceptions.
create_exception_from_error_code(error_code, error_message)
Create an appropriate exception instance from an error code and message.