about summary refs log tree commit diff
path: root/kittybox-rs/src/media
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-07-10 14:52:43 +0300
committerVika <vika@fireburn.ru>2022-07-10 14:52:43 +0300
commit3a7af37527c7752b42d518ec719a479254d6ba96 (patch)
tree5a51a8167d31330bd6af0f82858160a9e2759c6c /kittybox-rs/src/media
parent25183f2ed7802375f15cb0069af7bee6dd2c7afd (diff)
downloadkittybox-3a7af37527c7752b42d518ec719a479254d6ba96.tar.zst
micropub: move MicropubError into kittybox-util
Looks like this shared data structure will be useful to me later when
splitting off the media endpoint into its own crate.
Diffstat (limited to 'kittybox-rs/src/media')
-rw-r--r--kittybox-rs/src/media/mod.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/kittybox-rs/src/media/mod.rs b/kittybox-rs/src/media/mod.rs
index e9e91ac..4a253d0 100644
--- a/kittybox-rs/src/media/mod.rs
+++ b/kittybox-rs/src/media/mod.rs
@@ -2,20 +2,13 @@ use axum::{
     extract::{Extension, Host, multipart::{Multipart, MultipartError}, Path},
     response::{IntoResponse, Response}, headers::HeaderValue,
 };
-use crate::{micropub::{MicropubError, ErrorType}, tokenauth::User};
+use kittybox_util::error::{MicropubError, ErrorType};
+use crate::tokenauth::User;
 
 pub mod storage;
 use storage::{MediaStore, MediaStoreError, Metadata, ErrorKind};
 pub use storage::file::FileStore;
 
-impl From<MultipartError> for MicropubError {
-    fn from(err: MultipartError) -> Self {
-        Self {
-            error: ErrorType::InvalidRequest,
-            error_description: format!("multipart/form-data error: {}", err)
-        }
-    }
-}
 impl From<MediaStoreError> for MicropubError {
     fn from(err: MediaStoreError) -> Self {
         Self {
@@ -47,7 +40,10 @@ pub async fn upload<S: MediaStore>(
             }.into_response();
         },
         Err(err) => {
-            return MicropubError::from(err).into_response();
+            return MicropubError {
+                error: ErrorType::InternalServerError,
+                error_description: format!("Error while parsing multipart/form-data: {}", err)
+            }.into_response();
         },
     };
     let metadata: Metadata = (&field).into();