mirror of
https://github.com/DefectingCat/candy
synced 2025-07-15 16:51:34 +00:00
handle internal server error
This commit is contained in:
@ -47,7 +47,7 @@ pub async fn handle_file(path: &str) -> Result<CandyBody<Bytes>> {
|
||||
let cache = get_cache().read()?;
|
||||
match cache.get(path) {
|
||||
Some(time) => {
|
||||
dbg!(time, last_modified);
|
||||
// dbg!(time, last_modified);
|
||||
}
|
||||
None => {
|
||||
drop(cache);
|
||||
@ -79,3 +79,15 @@ pub fn not_found() -> Response<CandyBody<Bytes>> {
|
||||
.body(Full::new(NOT_FOUND.into()).map_err(|e| match e {}).boxed())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
static INTERNAL_SERVER_ERROR: &[u8] = b"Internal Server Error";
|
||||
pub fn internal_server_error() -> Response<CandyBody<Bytes>> {
|
||||
Response::builder()
|
||||
.status(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.body(
|
||||
Full::new(INTERNAL_SERVER_ERROR.into())
|
||||
.map_err(|e| match e {})
|
||||
.boxed(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
http::{handle_file, not_found, CandyBody},
|
||||
http::{handle_file, internal_server_error, not_found, CandyBody},
|
||||
utils::{find_route, parse_assets_path},
|
||||
};
|
||||
|
||||
@ -54,8 +54,7 @@ impl SettingHost {
|
||||
warn!("{err}");
|
||||
not_found()
|
||||
}
|
||||
// TODO: handle other error
|
||||
_ => todo!(),
|
||||
_ => internal_server_error(),
|
||||
};
|
||||
let end_time = (Instant::now() - start_time).as_micros() as f32;
|
||||
let end_time = end_time / 1000_f32;
|
||||
|
Reference in New Issue
Block a user