Skip to main content

autumn_plugin_aws_lambda/
error.rs

1//! Errors.
2
3/// Errors that stop the plugin at startup.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum PluginError {
7    /// `server.unix_socket` is set. The proxy needs TCP.
8    #[error("the Lambda plugin does not support server.unix_socket; remove it")]
9    UnixSocketUnsupported,
10    /// `server.tls` is set. The proxy sends plain HTTP.
11    #[error("the Lambda plugin does not support server.tls; Lambda terminates TLS")]
12    TlsUnsupported,
13    /// `server.port` is `0`. The plugin cannot know the port.
14    #[error("server.port is 0; set a fixed port")]
15    ZeroPort,
16    /// Required Lambda environment variables are missing or not valid.
17    #[error(
18        "the Lambda environment is not complete; missing or not valid: {}",
19        names.join(", ")
20    )]
21    #[non_exhaustive]
22    MissingEnv {
23        /// The names of the missing or incorrect variables.
24        names: Vec<&'static str>,
25    },
26    /// The plugin cannot start the runtime thread.
27    #[error("cannot start the Lambda runtime thread: {0}")]
28    Runtime(#[source] std::io::Error),
29    /// `server.host` is not an IP address or `localhost`.
30    #[error(
31        "server.host {host:?} is not an IP address or localhost; set AwsLambdaPlugin::upstream"
32    )]
33    #[non_exhaustive]
34    InvalidHost {
35        /// The value of `server.host`.
36        host: String,
37    },
38}