summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/view.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/view.rs b/src/view.rs
index ba15915..2062522 100644
--- a/src/view.rs
+++ b/src/view.rs
@@ -140,8 +140,10 @@ async fn index(
None => data.0.choose(&mut thread_rng()),
};
- let thing = thing.ok_or_else(|| error::ErrorNotFound("Not found"))?;
- let (index, thing) = thing.to_owned();
+ let (index, thing) = match thing {
+ Some(thing) => thing.to_owned(),
+ None => return Err(error::ErrorNotFound("Not found")),
+ };
let response = Suggestion { thing, req, index };
let response = response
@@ -161,7 +163,10 @@ struct SlackMessage<'a> {
async fn slack_troubleshoot(data: web::Data<Things>) -> error::Result<impl Responder> {
let thing = data.0.choose(&mut thread_rng());
- let (_, thing) = thing.ok_or_else(|| error::ErrorNotFound("Not found"))?;
+ let (_, thing) = match thing {
+ Some(thing) => thing.to_owned(),
+ None => return Err(error::ErrorNotFound("Not found")),
+ };
let response = SlackMessage {
response_type: "in_channel",