cleanup
This commit is contained in:
27
server/src/http/error.rs
Normal file
27
server/src/http/error.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use actix_web::error::ResponseError;
|
||||
use actix_web::http::header::ContentType;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::HttpResponse;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum WebsocketResponseError {}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum HttpServerResultError {
|
||||
#[error("Telemetry Not Found: {tlm}")]
|
||||
TlmNotFound { tlm: String },
|
||||
}
|
||||
|
||||
impl ResponseError for HttpServerResultError {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match *self {
|
||||
HttpServerResultError::TlmNotFound { .. } => StatusCode::NOT_FOUND,
|
||||
}
|
||||
}
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::build(self.status_code())
|
||||
.insert_header(ContentType::html())
|
||||
.body(self.to_string())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user