1use common_macro::stack_trace_debug;
16use snafu::{Location, Snafu};
17
18use crate::ir::create_expr::{CreateDatabaseExprBuilderError, CreateTableExprBuilderError};
19#[cfg(feature = "unstable")]
20use crate::utils::process::Pid;
21
22pub type Result<T> = std::result::Result<T, Error>;
23
24#[derive(Snafu)]
25#[snafu(visibility(pub))]
26#[stack_trace_debug]
27pub enum Error {
28 #[snafu(display("Failed to create a file: {}", path))]
29 CreateFile {
30 path: String,
31 #[snafu(implicit)]
32 location: Location,
33 #[snafu(source)]
34 error: std::io::Error,
35 },
36
37 #[snafu(display("Failed to write a file: {}", path))]
38 WriteFile {
39 path: String,
40 #[snafu(implicit)]
41 location: Location,
42 #[snafu(source)]
43 error: std::io::Error,
44 },
45
46 #[snafu(display("Unexpected, violated: {violated}"))]
47 Unexpected {
48 violated: String,
49 #[snafu(implicit)]
50 location: Location,
51 },
52
53 #[snafu(display("Failed to build create table expr"))]
54 BuildCreateTableExpr {
55 #[snafu(source)]
56 error: CreateTableExprBuilderError,
57 #[snafu(implicit)]
58 location: Location,
59 },
60
61 #[snafu(display("Failed to build create database expr"))]
62 BuildCreateDatabaseExpr {
63 #[snafu(source)]
64 error: CreateDatabaseExprBuilderError,
65 #[snafu(implicit)]
66 location: Location,
67 },
68
69 #[snafu(display("No droppable columns"))]
70 DroppableColumns {
71 #[snafu(implicit)]
72 location: Location,
73 },
74
75 #[snafu(display("Failed to execute query: {}", sql))]
76 ExecuteQuery {
77 sql: String,
78 #[snafu(source)]
79 error: sqlx::error::Error,
80 #[snafu(implicit)]
81 location: Location,
82 },
83
84 #[snafu(display("Failed to assert: {}", reason))]
85 Assert {
86 reason: String,
87 #[snafu(implicit)]
88 location: Location,
89 },
90
91 #[snafu(display("Child process exited unexpected"))]
92 UnexpectedExited {
93 #[snafu(implicit)]
94 location: Location,
95 },
96
97 #[snafu(display("Failed to spawn a child process"))]
98 SpawnChild {
99 #[snafu(implicit)]
100 location: Location,
101 #[snafu(source)]
102 error: std::io::Error,
103 },
104
105 #[cfg(feature = "unstable")]
106 #[snafu(display("Failed to kill a process, pid: {}", pid))]
107 KillProcess {
108 #[snafu(implicit)]
109 location: Location,
110 #[snafu(source)]
111 error: nix::Error,
112 pid: Pid,
113 },
114}