* @brief Set appropriate Python exception based on StringZilla status code and error detail. * @param[in] status The StringZilla status code * @param[in] error_detail Detailed error message from StringZilla (never NULL) * @param[in] context Context string describing the operation (e.g., "Levenshtein initialization") */
| 52 | * @param[in] context Context string describing the operation (e.g., "Levenshtein initialization") |
| 53 | */ |
| 54 | static void set_stringzilla_error(sz_status_t status, char const *error_detail, char const *context) { |
| 55 | switch (status) { |
| 56 | case sz_bad_alloc_k: PyErr_Format(PyExc_MemoryError, "%s: %s", context, error_detail); break; |
| 57 | case sz_invalid_utf8_k: PyErr_Format(PyExc_ValueError, "%s: %s", context, error_detail); break; |
| 58 | case sz_overflow_risk_k: PyErr_Format(PyExc_OverflowError, "%s: %s", context, error_detail); break; |
| 59 | case sz_unexpected_dimensions_k: PyErr_Format(PyExc_ValueError, "%s: %s", context, error_detail); break; |
| 60 | case sz_missing_gpu_k: |
| 61 | case sz_device_code_mismatch_k: |
| 62 | case sz_device_memory_mismatch_k: |
| 63 | default: PyErr_Format(PyExc_RuntimeError, "%s: %s", context, error_detail); break; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | #pragma region Forward Declarations |
| 68 |
no outgoing calls
no test coverage detected
searching dependent graphs…