Convert GraphBit core errors to Python exceptions with enhanced error mapping
(error: graphbit_core::errors::GraphBitError)
| 127 | |
| 128 | /// Convert GraphBit core errors to Python exceptions with enhanced error mapping |
| 129 | pub(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 |
| 164 | pub(crate) fn python_error_to_py_err(error: PythonBindingError) -> PyErr { |
no test coverage detected