1use snafu::Snafu;
16
17pub static LOG_CATEGORY: &str = "core";
18
19#[derive(Debug, Snafu)]
20pub enum Error {
21 #[snafu(display("Invalid error: {message}"))]
22 Invalid { message: String },
23 #[snafu(display("Plugin {category} not found"))]
24 NotFound { category: String },
25}
26
27pub fn new_internal_error(status: u16, message: String) -> pingora::BError {
29 pingora::Error::because(
30 pingora::ErrorType::HTTPStatus(status),
31 message,
32 pingora::Error::new(pingora::ErrorType::InternalError),
33 )
34}
35
36mod ctx;
37mod http_header;
38mod http_response;
39mod notification;
40mod plugin;
41mod service;
42mod ttl_lru_limit;
43mod util;
44
45pub use ctx::*;
46pub use http_header::*;
47pub use http_response::*;
48pub use notification::*;
49pub use pingora_limits::inflight::*;
50pub use pingora_limits::rate::*;
51pub use plugin::*;
52pub use service::*;
53pub use tinyufo::TinyUfo;
54pub use ttl_lru_limit::*;
55pub use util::*;
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn test_new_internal_error() {
63 let err = new_internal_error(500, "Internal Server Error".to_string());
64 assert_eq!(
65 err.to_string().trim(),
66 "HTTPStatus context: Internal Server Error cause: InternalError"
67 );
68 }
69}