about summary refs log tree commit diff
path: root/src/media/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/media/mod.rs')
-rw-r--r--src/media/mod.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/media/mod.rs b/src/media/mod.rs
index 32b8405..3ed6810 100644
--- a/src/media/mod.rs
+++ b/src/media/mod.rs
@@ -13,10 +13,10 @@ pub use storage::file::FileStore;
 
 impl From<MediaStoreError> for MicropubError {
     fn from(err: MediaStoreError) -> Self {
-        Self {
-            error: ErrorType::InternalServerError,
-            error_description: format!("{}", err)
-        }
+        Self::new(
+            ErrorType::InternalServerError,
+            format!("media store error: {}", err)
+        )
     }
 }
 
@@ -27,25 +27,25 @@ pub(crate) async fn upload<S: MediaStore, A: AuthBackend>(
     mut upload: Multipart
 ) -> Response {
     if !user.check_scope(&Scope::Media) {
-        return MicropubError {
-            error: ErrorType::NotAuthorized,
-            error_description: "Interacting with the media storage requires the \"media\" scope.".to_owned()
-        }.into_response();
+        return MicropubError::from_static(
+            ErrorType::NotAuthorized,
+            "Interacting with the media storage requires the \"media\" scope."
+        ).into_response();
     }
     let host = user.me.authority();
     let field = match upload.next_field().await {
         Ok(Some(field)) => field,
         Ok(None) => {
-            return MicropubError {
-                error: ErrorType::InvalidRequest,
-                error_description: "Send multipart/form-data with one field named file".to_owned()
-            }.into_response();
+            return MicropubError::from_static(
+                ErrorType::InvalidRequest,
+                "Send multipart/form-data with one field named file"
+            ).into_response();
         },
         Err(err) => {
-            return MicropubError {
-                error: ErrorType::InternalServerError,
-                error_description: format!("Error while parsing multipart/form-data: {}", err)
-            }.into_response();
+            return MicropubError::new(
+                ErrorType::InternalServerError,
+                format!("Error while parsing multipart/form-data: {}", err)
+            ).into_response();
         },
     };
     let metadata: Metadata = (&field).into();