about summary refs log tree commit diff
path: root/src/micropub/get.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2021-05-04 21:14:31 +0300
committerVika <vika@fireburn.ru>2021-05-04 21:14:31 +0300
commit1a78c48bd86ff72cc9c7020e69ec9a77302a2f8b (patch)
tree7a0bbd3f520d0eecdb8bcadc23e62f7f1f5757f5 /src/micropub/get.rs
parentb0763ade5d16a68654256b4cbfd029210981970d (diff)
Made StorageErrors directly convertible into Micropub JSON responses
Diffstat (limited to 'src/micropub/get.rs')
-rw-r--r--src/micropub/get.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/micropub/get.rs b/src/micropub/get.rs
index 9a12316..2b367fd 100644
--- a/src/micropub/get.rs
+++ b/src/micropub/get.rs
@@ -23,10 +23,7 @@ where
             let channels: Vec<MicropubChannel>;
             match backend.get_channels(&user).await {
                 Ok(chans) => channels = chans,
-                Err(err) => return Ok(Response::builder(500).body(json!({
-                    "error": "database_error",
-                    "error_description": format!("Couldn't fetch channel list from the database: {:?}", err)
-                })).build())
+                Err(err) => return Ok(err.into())
             }
             Ok(Response::builder(200).body(json!({
                 "q": ["source", "config", "channel"],
@@ -38,10 +35,7 @@ where
             let channels: Vec<MicropubChannel>;
             match backend.get_channels(&user).await {
                 Ok(chans) => channels = chans,
-                Err(err) => return Ok(Response::builder(500).body(json!({
-                    "error": "database_error",
-                    "error_description": format!("Couldn't fetch channel list from the database: {:?}", err)
-                })).build())
+                Err(err) => return Ok(err.into())
             }
             return Ok(Response::builder(200).body(json!(channels)).build())
         }
@@ -54,10 +48,7 @@ where
                         } else {
                             return Ok(Response::builder(404).build())
                         },
-                        Err(err) => return Ok(Response::builder(500).body(json!({
-                            "error": "database_error",
-                            "error_description": err
-                        })).build())
+                        Err(err) => return Ok(err.into())
                     }
                 } else {
                     return Ok(Response::builder(400).body(json!({