From 21fb842ad0bca83cd36e101f4067caccb73eb000 Mon Sep 17 00:00:00 2001 From: benwis Date: Thu, 28 Sep 2023 15:38:41 -0700 Subject: [PATCH] Make error message only render when called --- integrations/axum/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/integrations/axum/src/lib.rs b/integrations/axum/src/lib.rs index 7466886d8d..01607e91cf 100644 --- a/integrations/axum/src/lib.rs +++ b/integrations/axum/src/lib.rs @@ -653,12 +653,13 @@ where // 2. Find RouteListing in paths. This should probably be optimized, we probably don't want to // search for this every time let listing: &RouteListing = - paths.iter().find(|r| r.path() == path).expect(&format!( - "Failed to find the route {} requested by the user. This \ - suggests that the routing rules in the Router that call this \ - handler needs to be edited!", - path - )); + paths.iter().find(|r| r.path() == path).unwrap_or_else(|_| { + panic!( + "Failed to find the route {path} requested by the user. \ + This suggests that the routing rules in the Router that \ + call this handler needs to be edited!" + ) + }); // 3. Match listing mode against known, and choose function match listing.mode() { SsrMode::OutOfOrder => ooo(req),