This commit is contained in:
2024-12-30 17:22:16 -05:00
parent 10e80a0c2d
commit c7ca250b66
20 changed files with 529 additions and 472 deletions

27
server/src/http/error.rs Normal file
View 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())
}
}