1use std::error::Error;
6
7use crate::proxy_wasm::types::Status;
8
9use super::GrpcStatus;
10
11#[derive(Debug, thiserror::Error)]
13#[non_exhaustive]
14pub enum GrpcCallError {
15 #[error(transparent)]
17 Proxy(#[from] GrpcProxyError),
18
19 #[error("Invalid upstream '{0}'")]
21 InvalidUpstream(String),
22
23 #[error(transparent)]
25 Encode(Box<dyn Error + Send + Sync>),
26}
27
28#[derive(Debug, thiserror::Error)]
30#[error("Proxy status problem: {0:?}")]
31pub struct GrpcProxyError(Status);
32
33impl GrpcProxyError {
34 pub(super) fn new(status: Status) -> Self {
35 Self(status)
36 }
37}
38
39#[derive(Debug, thiserror::Error)]
41#[non_exhaustive]
42pub enum GrpcClientError {
43 #[error(transparent)]
45 Call(#[from] GrpcCallError),
46
47 #[error("Request awaited on create context event")]
49 AwaitedOnCreateContext,
50
51 #[error("Empty content")]
53 EmptyContent,
54
55 #[error(transparent)]
57 Decode(Box<dyn Error + Send + Sync>),
58
59 #[error("Bad gRPC status: {0}")]
61 Status(GrpcStatus),
62}