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_config::errors::ConfigError;
5use slim_datapath::errors::DataPathError;
6use thiserror::Error;
7use tonic::Status;
8
9#[derive(Error, Debug)]
10pub enum ControllerError {
11    // Configuration / setup
12    #[error("configuration error")]
13    ConfigError(#[from] ConfigError),
14
15    // Connection lifecycle
16    #[error("controller already started")]
17    AlreadyStarted,
18    #[error("controller already stopped")]
19    AlreadyStopped,
20    #[error("timeout waiting for shutdown to complete")]
21    ShutdownTimeout,
22    #[error("connection canceled")]
23    Canceled,
24    #[error("grpc error")]
25    GrpcError(#[from] Status),
26
27    // Clients / Servers errors
28    #[error("client already running: {0}")]
29    ClientAlreadyRunning(String),
30    #[error("server already running: {0}")]
31    ServerAlreadyRunning(String),
32
33    #[error("malformed name: {0}")]
34    MalformedName(String),
35
36    // Propagated lower-level errors
37    #[error("datapath error")]
38    Datapath(#[from] DataPathError),
39    #[error("error sending message to data plane: {0}")]
40    DatapathSendError(String),
41    #[error("message error")]
42    MessageError(#[from] slim_datapath::messages::utils::MessageError),
43
44    // Payload / validation
45    #[error("payload missing")]
46    PayloadMissing,
47}