Skip to main content

tests_fuzz/
error.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use 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("Kafka WAL helper request failed, operation: {}", operation))]
85    KafkaWalHelperRequest {
86        operation: String,
87        #[snafu(source)]
88        error: reqwest::Error,
89        #[snafu(implicit)]
90        location: Location,
91    },
92
93    #[snafu(display(
94        "Kafka WAL helper returned non-success status, operation: {}, status: {}, body: {}",
95        operation,
96        status,
97        body
98    ))]
99    KafkaWalHelperStatus {
100        operation: String,
101        status: reqwest::StatusCode,
102        body: String,
103        #[snafu(implicit)]
104        location: Location,
105    },
106
107    #[snafu(display("Failed to assert: {}", reason))]
108    Assert {
109        reason: String,
110        #[snafu(implicit)]
111        location: Location,
112    },
113
114    #[snafu(display("Child process exited unexpected"))]
115    UnexpectedExited {
116        #[snafu(implicit)]
117        location: Location,
118    },
119
120    #[snafu(display("Failed to spawn a child process"))]
121    SpawnChild {
122        #[snafu(implicit)]
123        location: Location,
124        #[snafu(source)]
125        error: std::io::Error,
126    },
127
128    #[cfg(feature = "unstable")]
129    #[snafu(display("Failed to kill a process, pid: {}", pid))]
130    KillProcess {
131        #[snafu(implicit)]
132        location: Location,
133        #[snafu(source)]
134        error: nix::Error,
135        pid: Pid,
136    },
137}