mirror of
https://github.com/katanemo/plano.git
synced 2026-05-04 13:23:00 +02:00
Code refactor and some improvements - see description (#194)
This commit is contained in:
parent
aa30353c85
commit
c6ba28dfcc
15 changed files with 100 additions and 115 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