1use std::any::Any;
16
17use common_error::ext::ErrorExt;
18use common_macro::stack_trace_debug;
19use snafu::{Location, Snafu};
20use tokio::task::JoinError;
21
22pub type Result<T> = std::result::Result<T, Error>;
23
24#[derive(Snafu)]
25#[snafu(visibility(pub(crate)))]
26#[stack_trace_debug]
27pub enum Error {
28 #[snafu(display("Failed to build runtime"))]
29 BuildRuntime {
30 #[snafu(source)]
31 error: std::io::Error,
32 #[snafu(implicit)]
33 location: Location,
34 },
35
36 #[snafu(display("Failed to build runtime rate limiter"))]
37 BuildRuntimeRateLimiter {
38 #[snafu(implicit)]
39 location: Location,
40 #[snafu(source)]
41 error: ratelimit::Error,
42 },
43
44 #[snafu(display("Repeated task {} is already started", name))]
45 IllegalState {
46 name: String,
47 #[snafu(implicit)]
48 location: Location,
49 },
50
51 #[snafu(display("Failed to wait for repeated task {} to stop", name))]
52 WaitGcTaskStop {
53 name: String,
54 #[snafu(source)]
55 error: JoinError,
56 #[snafu(implicit)]
57 location: Location,
58 },
59}
60
61impl ErrorExt for Error {
62 fn as_any(&self) -> &dyn Any {
63 self
64 }
65}