springql_core/api/
error.rs

1// This file is part of https://github.com/SpringQL/SpringQL which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details.
2
3//! Error type.
4
5pub mod foreign_info;
6
7use thiserror::Error;
8
9use crate::{api::error::foreign_info::ForeignInfo, time::TimeError};
10
11/// Result type
12pub type Result<T> = std::result::Result<T, SpringError>;
13
14/// Error type
15#[allow(missing_docs)]
16#[derive(Debug, Error)]
17pub enum SpringError {
18    #[error("I/O error related to foreign system: {foreign_info:?}")]
19    ForeignIo {
20        foreign_info: ForeignInfo,
21        source: anyhow::Error,
22    },
23
24    #[error("Timeout when getting an input from foreign source: {foreign_info:?}")]
25    ForeignSourceTimeout {
26        foreign_info: ForeignInfo,
27        source: anyhow::Error,
28    },
29
30    #[error("Timeout when getting an input from a stream ({task_name})")]
31    InputTimeout {
32        task_name: String,
33        source: anyhow::Error,
34    },
35
36    #[error("I/O error inside SpringQL-core")]
37    SpringQlCoreIo(anyhow::Error),
38
39    #[error("another thread sharing the same resource got panic")]
40    ThreadPoisoned(anyhow::Error),
41
42    #[error("invalid config")]
43    InvalidConfig { source: anyhow::Error },
44
45    #[error("invalid option (key `{key:?}`, value `{value:?}`)")]
46    InvalidOption {
47        key: String,
48        value: String,
49        source: anyhow::Error,
50    },
51
52    #[error(r#"invalid format ("{s}")"#)]
53    InvalidFormat { s: String, source: anyhow::Error },
54
55    #[error("requested {resource} but its not available")]
56    Unavailable {
57        resource: String,
58        source: anyhow::Error,
59    },
60
61    #[error("SQL error")]
62    Sql(anyhow::Error),
63
64    /// Occurs only when a value is fetched from a SpringSinkRow.
65    #[error("unexpectedly got NULL")]
66    Null {
67        /// Column index
68        i_col: usize,
69    },
70
71    #[error("Time conversion error {0}")]
72    Time(TimeError),
73}