Skip to main content

sqlload_python_host/crossing/
errors.rs

1use pyo3::PyErr;
2use sqlload::python_sources::errors::ReadError;
3
4/// Why a table generator's data could not be read.
5#[derive(Debug)]
6pub enum CrossError {
7    /// The generator raised, or yielded something that is not table data.
8    Python(PyErr),
9    /// The data could not become Arrow (malformed JSON, a non-object row).
10    Data(String),
11    /// An `sl.http` job failed; it says whether running it again may succeed.
12    Http(ReadError),
13}
14
15impl std::fmt::Display for CrossError {
16    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            Self::Python(error) => write!(formatter, "{error}"),
19            Self::Data(reason) => formatter.write_str(reason),
20            Self::Http(error) => write!(formatter, "{error}"),
21        }
22    }
23}