Skip to content

Commit 98b8bf3

Browse files
committed
async-server: return Code::UNKNOWN(500) when handler failed
The client should know the error of handler. Signed-off-by: Tim Zhang <tim@hyper.sh>
1 parent 1e5b129 commit 98b8bf3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/asynchronous/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ async fn handle_request(
310310
}
311311
trace!("Got Message request {:?}", req);
312312

313+
let stream_id = header.stream_id;
313314
let path = format!("/{}/{}", req.service, req.method);
314315
if let Some(x) = methods.get(&path) {
315316
let method = x;
@@ -327,6 +328,10 @@ async fn handle_request(
327328
}
328329
Err(e) => {
329330
error!("method handle {} get error {:?}", path, e);
331+
let status = get_status(Code::UNKNOWN, e);
332+
if let Err(e) = respond_with_status(tx, stream_id, status).await {
333+
error!("respond get error {:?}", e);
334+
}
330335
}
331336
}
332337
} else {

0 commit comments

Comments
 (0)