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("grpc error")]
23    GrpcError(#[from] Status),
24
25    // Clients / Servers errors
26    #[error("client already running: {0}")]
27    ClientAlreadyRunning(String),
28    #[error("server already running: {0}")]
29    ServerAlreadyRunning(String),
30
31    #[error("malformed name: {0}")]
32    MalformedName(String),
33
34    // Propagated lower-level errors
35    #[error("datapath error")]
36    Datapath(#[from] DataPathError),
37    #[error("error sending message to data plane: {0}")]
38    DatapathSendError(String),
39    #[error("message error")]
40    MessageError(#[from] slim_datapath::messages::utils::MessageError),
41
42    // Payload / validation
43    #[error("payload missing")]
44    PayloadMissing,
45}