summaryrefslogtreecommitdiff
path: root/src/ui/assets.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/assets.rs')
-rw-r--r--src/ui/assets.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/ui/assets.rs b/src/ui/assets.rs
index 0ca9593..ede1f7c 100644
--- a/src/ui/assets.rs
+++ b/src/ui/assets.rs
@@ -1,4 +1,4 @@
-use ::mime::{FromStrError, Mime};
+use ::mime::Mime;
use axum::{
http::{StatusCode, header},
response::{IntoResponse, Response},
@@ -6,7 +6,10 @@ use axum::{
use rust_embed::EmbeddedFile;
use super::{error::NotFound, mime};
-use crate::error::Internal;
+use crate::error::{
+ Internal,
+ failed::{Failed, ResultExt},
+};
#[derive(rust_embed::Embed)]
#[folder = "$OUT_DIR/ui"]
@@ -15,7 +18,7 @@ pub struct Assets;
impl Assets {
pub fn load(path: impl AsRef<str>) -> Result<Asset, Error> {
let path = path.as_ref();
- let mime = mime::from_path(path)?;
+ let mime = mime::from_path(path).fail("Failed to determine MIME type from asset path")?;
Self::get(path)
.map(|file| Asset(mime, file))
@@ -49,14 +52,14 @@ pub enum Error {
#[error("not found: {0}")]
NotFound(String),
#[error(transparent)]
- Mime(#[from] FromStrError),
+ Failed(#[from] Failed),
}
impl IntoResponse for Error {
fn into_response(self) -> Response {
match self {
Self::NotFound(_) => NotFound(self.to_string()).into_response(),
- Self::Mime(_) => Internal::from(self).into_response(),
+ Self::Failed(_) => Internal::from(self).into_response(),
}
}
}