handle not found error

This commit is contained in:
yggverse 2025-07-03 22:34:09 +03:00
parent b1360eab2e
commit 9980d20c21
3 changed files with 9 additions and 3 deletions

View file

@ -9,6 +9,7 @@ pub enum Response<'a> {
},
NotFound {
query: &'a str,
error: String,
},
File(&'a [u8]),
Directory {

View file

@ -148,9 +148,9 @@ impl Connection {
);
self.session.template.access_denied()
}
Response::NotFound { query } => {
Response::NotFound { query, error } => {
eprintln!(
"[{}] < [{}] requested resource `{query}` not found.",
"[{}] < [{}] requested resource `{query}` not found: {error}.",
self.address.server, self.address.client
);
self.session.template.not_found()

View file

@ -54,7 +54,12 @@ impl Public {
}
c
}
Err(_) => return callback(Response::NotFound { query }),
Err(e) => {
return callback(Response::NotFound {
query,
error: e.to_string(),
});
}
}
};
match fs::metadata(&p) {