autumn_plugin_grpc/
error.rs1use std::net::SocketAddr;
4
5use crate::config::ConfigError;
6
7#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum GrpcError {
11 #[error(transparent)]
13 Config(#[from] ConfigError),
14 #[error("cannot bind gRPC listener on {addr}: {source}")]
16 Bind {
17 addr: SocketAddr,
19 source: std::io::Error,
21 },
22 #[error("cannot build gRPC reflection: {0}")]
24 Reflection(String),
25 #[error("cannot set up gRPC TLS: {0}")]
27 Tls(String),
28 #[error("gRPC service `{0}` is added twice; each service name must be unique")]
31 DuplicateService(String),
32 #[error("the gRPC server cannot start in state `{0}`")]
34 NotIdle(crate::lifecycle::Lifecycle),
35 #[error("only one gRPC plugin can use `listener = \"shared\"`; `[{0}]` uses it already")]
37 SharedListenerTaken(String),
38 #[error(
40 "Autumn TLS (`[server.tls]`) in autumn-web {0} does not offer HTTP/2 (ALPN `h2`), so gRPC \
41 clients cannot connect; autumn-foundation/autumn#2321 fixes this in the next Autumn \
42 release. Use `listener = \"dedicated\"`, or end TLS at a proxy"
43 )]
44 SharedListenerNeedsH2(&'static str),
45 #[error(
48 "gRPC client `{0}` is registered twice: two registrations of one type, or registrations in two plugins"
49 )]
50 DuplicateClient(String),
51 #[error(
53 "gRPC client `{name}` has no endpoint; set `endpoint` in `[{section}.clients.{name}]`, or add `client_double(\"{name}\", ..)`"
54 )]
55 ClientWithoutEndpoint {
56 name: String,
58 section: String,
60 },
61 #[error("gRPC client double `{0}` has no client; add `GrpcPlugin::client(\"{0}\", ..)`")]
63 DoubleWithoutClient(String),
64 #[error("cannot set up gRPC client `{name}`: {message}")]
66 ClientSetup {
67 name: String,
69 message: String,
71 },
72 #[error("the gRPC server is already started")]
74 AlreadyStarted,
75}