Skip to main content

sqlload_python_host/host/main/
read_error.rs

1//! A table function's exception as the engine's read error.
2
3use pyo3::exceptions::{PyConnectionError, PyTimeoutError};
4use pyo3::{PyErr, Python};
5use sqlload::python_sources::errors::ReadError;
6
7use crate::host::main::error_text::error_text;
8
9/// A table function's exception as a read error, retryable when it is a `ConnectionError` or `TimeoutError` (or a subclass), as a dropped connection or an `sl.http` job that outlasted its retries raises.
10pub fn read_error(error: &PyErr) -> ReadError {
11    let retryable = Python::attach(|py| {
12        error.is_instance_of::<PyConnectionError>(py) || error.is_instance_of::<PyTimeoutError>(py)
13    });
14    ReadError {
15        message: error_text(error),
16        retryable,
17    }
18}