2024-10-18 12:53:44 -07:00
|
|
|
use proxy_wasm::types::Status;
|
|
|
|
|
|
|
|
|
|
use crate::ratelimit;
|
|
|
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
|
pub enum ClientError {
|
|
|
|
|
#[error("Error dispatching HTTP call to `{upstream_name}/{path}`, error: {internal_status:?}")]
|
|
|
|
|
DispatchError {
|
|
|
|
|
upstream_name: String,
|
|
|
|
|
path: String,
|
|
|
|
|
internal_status: Status,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
|
pub enum ServerError {
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
HttpDispatch(ClientError),
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
Deserialization(serde_json::Error),
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
Serialization(serde_json::Error),
|
|
|
|
|
#[error("{0}")]
|
|
|
|
|
LogicError(String),
|
2024-10-21 15:04:15 -07:00
|
|
|
#[error("upstream application error host={host}, path={path}, status={status}, body={body}")]
|
2024-10-18 12:53:44 -07:00
|
|
|
Upstream {
|
2024-10-21 15:04:15 -07:00
|
|
|
host: String,
|
2024-10-18 12:53:44 -07:00
|
|
|
path: String,
|
|
|
|
|
status: String,
|
2024-10-21 15:04:15 -07:00
|
|
|
body: String,
|
2024-10-18 12:53:44 -07:00
|
|
|
},
|
|
|
|
|
#[error("jailbreak detected: {0}")]
|
|
|
|
|
Jailbreak(String),
|
|
|
|
|
#[error("{why}")]
|
|
|
|
|
NoMessagesFound { why: String },
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
ExceededRatelimit(ratelimit::Error),
|
|
|
|
|
#[error("{why}")]
|
|
|
|
|
BadRequest { why: String },
|
|
|
|
|
}
|