MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / to_py_error

Function to_py_error

python/src/errors.rs:129–161  ·  view source on GitHub ↗

Convert GraphBit core errors to Python exceptions with enhanced error mapping

(error: graphbit_core::errors::GraphBitError)

Source from the content-addressed store, hash-verified

127
128/// Convert GraphBit core errors to Python exceptions with enhanced error mapping
129pub(crate) fn to_py_error(error: graphbit_core::errors::GraphBitError) -> PyErr {
130 use graphbit_core::errors::GraphBitError;
131
132 // Log the error for debugging
133 error!("GraphBit error in Python binding: {}", error);
134
135 let python_error = match error {
136 GraphBitError::Network { message, .. } => PythonBindingError::Network {
137 message: message.clone(),
138 retry_count: 1,
139 },
140 GraphBitError::Authentication { message, .. } => PythonBindingError::Authentication {
141 message: message.clone(),
142 provider: None,
143 },
144 GraphBitError::RateLimit { .. } => PythonBindingError::RateLimit {
145 message: "Rate limit exceeded".to_string(),
146 retry_after: None,
147 },
148 GraphBitError::Validation { message, .. } => PythonBindingError::Validation {
149 message: message.clone(),
150 field: "unknown".to_string(),
151 value: None,
152 },
153 GraphBitError::Configuration { message, .. } => PythonBindingError::Configuration {
154 message: message.clone(),
155 field: None,
156 },
157 _ => PythonBindingError::Core(error.to_string()),
158 };
159
160 python_error_to_py_err(python_error)
161}
162
163/// Convert Python binding errors to PyErr with appropriate exception types
164pub(crate) fn python_error_to_py_err(error: PythonBindingError) -> PyErr {

Callers 6

load_documentMethod · 0.85
__anext__Method · 0.85
__anext__Method · 0.85
streaming_responseMethod · 0.85

Calls 3

python_error_to_py_errFunction · 0.85
cloneMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected