mirror of
https://github.com/katanemo/plano.git
synced 2026-05-10 08:12:48 +02:00
add errors.rs
This commit is contained in:
parent
a10af71bc6
commit
8688757531
1 changed files with 39 additions and 0 deletions
39
crates/common/src/errors.rs
Normal file
39
crates/common/src/errors.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
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),
|
||||||
|
#[error("upstream error response authority={authority}, path={path}, status={status}")]
|
||||||
|
Upstream {
|
||||||
|
authority: String,
|
||||||
|
path: String,
|
||||||
|
status: String,
|
||||||
|
},
|
||||||
|
#[error("jailbreak detected: {0}")]
|
||||||
|
Jailbreak(String),
|
||||||
|
#[error("{why}")]
|
||||||
|
NoMessagesFound { why: String },
|
||||||
|
#[error(transparent)]
|
||||||
|
ExceededRatelimit(ratelimit::Error),
|
||||||
|
#[error("{why}")]
|
||||||
|
BadRequest { why: String },
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue