Skip to main content

slim_controller/
errors.rs

1// Copyright AGNTCY Contributors (https://github.com/agntcy)
2// SPDX-License-Identifier: Apache-2.0
3
4use slim_auth::errors::AuthError;
5use slim_config::grpc::errors::ConfigError;
6use slim_datapath::errors::DataPathError;
7use thiserror::Error;
8use tonic::Status;
9
10#[derive(Error, Debug)]
11pub enum ControllerError {
12    // Configuration / setup
13    #[error("configuration error")]
14    ConfigError(#[from] ConfigError),
15
16    // Connection lifecycle
17    #[error("controller already started")]
18    AlreadyStarted,
19    #[error("controller already stopped")]
20    AlreadyStopped,
21    #[error("timeout waiting for shutdown to complete")]
22    ShutdownTimeout,
23    #[error("grpc error")]
24    GrpcError(#[from] Status),
25
26    // Clients / Servers errors
27    #[error("client already running: {0}")]
28    ClientAlreadyRunning(String),
29    #[error("server already running: {0}")]
30    ServerAlreadyRunning(String),
31
32    #[error("malformed name: {0}")]
33    MalformedName(String),
34
35    // Propagated lower-level errors
36    #[error("datapath error")]
37    Datapath(#[from] DataPathError),
38    #[error("error sending message to data plane: {0}")]
39    DatapathSendError(String),
40    #[error("auth error")]
41    Auth(#[from] AuthError),
42    #[error("message error")]
43    MessageError(#[from] slim_datapath::messages::utils::MessageError),
44
45    // Payload / validation
46    #[error("payload missing")]
47    PayloadMissing,
48}