sqlness/
error.rs

1// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
2
3use std::path::PathBuf;
4
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8pub enum SqlnessError {
9    #[error("Unable to read from path {path}")]
10    ReadPath {
11        source: std::io::Error,
12        path: PathBuf,
13    },
14
15    #[error("Failed to parse toml file {file}, error: {source}")]
16    ParseToml {
17        source: toml::de::Error,
18        file: PathBuf,
19    },
20
21    #[error("IO operation failed, source error: {0}")]
22    IO(#[from] std::io::Error),
23
24    #[error("Cannot parse the result file. Not valid UTF-8 encoding")]
25    ReadResult(#[from] std::string::FromUtf8Error),
26
27    #[error("Run failed. {count} cases can't pass")]
28    RunFailed { count: usize },
29
30    #[error("Invalid regexp, source error: {0}")]
31    Regex(#[from] regex::Error),
32
33    #[error("Unknown interceptor prefix, value:{prefix}.")]
34    UnknownInterceptor { prefix: String },
35
36    #[error("Invalid interceptor context, prefix:{prefix}, msg:{msg}.")]
37    InvalidContext { prefix: String, msg: String },
38
39    #[error("Missing interceptor prefix, line:{line}.")]
40    MissingPrefix { line: String },
41}
42
43pub(crate) type Result<T> = std::result::Result<T, SqlnessError>;