1use wick_config::error::ManifestError;
2use wick_packet::TypeWrapper;
3
4#[derive(thiserror::Error, Debug)]
5#[allow(missing_docs)]
6#[non_exhaustive]
7pub enum Error {
8 #[error("Invalid output for operations {}. At this time postgres operations can have at most one output named 'output' of type 'object'", .0.join(", "))]
9 InvalidOutput(Vec<String>),
10
11 #[error("Failed to fetch result of query: {0}")]
12 Fetch(String),
13
14 #[error("Failed to fetch result of exec: {0}")]
15 Exec(String),
16
17 #[error("Unknown database scheme '{0}'")]
18 InvalidScheme(String),
19
20 #[error(
21 "To use in-memory SQLite databases, use the URL 'sqlite://memory'; to use a SQLite DB file, use a 'file://' URL"
22 )]
23 SqliteScheme,
24
25 #[error("Failed to prepare arguments: {0}")]
26 Prepare(String),
27
28 #[error("Failed to connect to MsSqlServer: {0}")]
29 MssqlConnect(String),
30
31 #[error("Failed to connect to Postgres Server: {0}")]
32 PostgresConnect(String),
33
34 #[error("Failed to open to Sqlite DB: {0}")]
35 SqliteConnect(String),
36
37 #[error("{0}")]
38 Pool(String),
39
40 #[error("Failed to get connection from pool: {0}")]
41 PoolConnection(String),
42
43 #[error("Failed to start DB transaction")]
44 TxStart,
45
46 #[error("Failed to commit DB transaction")]
47 TxCommit,
48
49 #[error("Failed to rollback DB transaction")]
50 TxRollback,
51
52 #[error("Operation failed: {0}")]
53 OperationFailed(String),
54
55 #[error("SQL Query failed, check log for details")]
56 QueryFailed,
57
58 #[error("SQL error reported within stream: {0}")]
59 ErrorInStream(String),
60
61 #[error("Query failed: {0}")]
62 Failed(String),
63
64 #[error("Missing positional argument '{0}'")]
65 MissingArgument(String),
66
67 #[error("Missing input")]
68 MissingInput,
69
70 #[error("Operation '{0}' not found on this component")]
71 MissingOperation(String),
72
73 #[error("Could not find a value for input '{0}' to bind to a positional argument")]
74 MissingPacket(String),
75
76 #[error("Could not encode wick type {} with value '{}' into the DB's type for {1}. Try a different value, type, or coersion within the SQL query.",.0.type_signature(),.0.inner())]
77 SqlServerEncodingFault(TypeWrapper, ConversionError),
78
79 #[error(transparent)]
80 ComponentError(wick_packet::Error),
81
82 #[error("Database connection not initialized")]
83 Uninitialized,
84
85 #[error(transparent)]
86 Configuration(#[from] ManifestError),
87
88 #[error("Resource valid but its value could not be retrieved")]
89 InvalidResourceConfig,
90
91 #[error("Got a row with no data")]
92 NoRow,
93}
94
95#[derive(thiserror::Error, Debug, Copy, Clone)]
96pub enum ConversionError {
97 #[error("i8")]
98 I8,
99 #[error("i16")]
100 I16,
101 #[error("i32")]
102 I32,
103 #[error("i64")]
104 I64,
105 #[error("u8")]
106 U8,
107 #[error("u16")]
108 U16,
109 #[error("u32")]
110 U32,
111 #[error("u64")]
112 U64,
113 #[error("f32")]
114 F32,
115 #[error("f64")]
116 F64,
117 #[error("bool")]
118 Bool,
119 #[error("string")]
120 String,
121 #[error("datetime")]
122 Datetime,
123 #[error("bytes")]
124 Bytes,
125 #[error("named")]
126 Named,
127 #[error("list")]
128 List,
129 #[error("optional")]
130 Optional,
131 #[error("map")]
132 Map,
133 #[error("link")]
134 Link,
135 #[error("object")]
136 Object,
137 #[error("anonymous struct")]
138 AnonymousStruct,
139}