Skip to content

Commit ca30358

Browse files
committed
fail with better error message
1 parent 7182614 commit ca30358

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/server/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ impl<State: Send + Sync + 'static> Server<State> {
254254
/// match or not, which means that the order of adding resources has no
255255
/// effect.
256256
pub fn at<'a>(&'a mut self, path: &'a str) -> Route<'a, State> {
257-
let router = Arc::get_mut(&mut self.router).unwrap();
257+
let router = Arc::get_mut(&mut self.router)
258+
.expect("Registering routes is not possible after the Server has started");
258259
Route::new(router, path.to_owned())
259260
}
260261

@@ -269,7 +270,8 @@ impl<State: Send + Sync + 'static> Server<State> {
269270
/// Middleware can only be added at the "top level" of an application,
270271
/// and is processed in the order in which it is applied.
271272
pub fn middleware(&mut self, m: impl Middleware<State>) -> &mut Self {
272-
let middleware = Arc::get_mut(&mut self.middleware).unwrap();
273+
let middleware = Arc::get_mut(&mut self.middleware)
274+
.expect("Registering middleware is not possible after the Server has started");
273275
middleware.push(Arc::new(m));
274276
self
275277
}

0 commit comments

Comments
 (0)