From a43312de2d1dc66e7547f41061c798564afc6896 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 1 Oct 2021 13:28:44 +1000 Subject: [PATCH] Don't panic in endpoints Does not tackle fixing previously already existing endpoints. --- daemon/src/routes_taker.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/src/routes_taker.rs b/daemon/src/routes_taker.rs index d26dd8f..132dfd8 100644 --- a/daemon/src/routes_taker.rs +++ b/daemon/src/routes_taker.rs @@ -120,13 +120,14 @@ pub async fn post_cfd_action( ) -> Result, status::BadRequest> { match action { CfdAction::Accept | CfdAction::Reject => { - unreachable!("The taker does not accept and reject"); + return Err(status::BadRequest(None)); } + CfdAction::Commit => { cfd_actor_address .do_send_async(taker_cfd::Commit { order_id: id }) .await - .expect("actor to always be available"); + .map_err(|e| status::BadRequest(Some(e.to_string())))?; } }