Skip to content

Commit 2d3f6dc

Browse files
authored
Send an html page with 500 responses (#10851)
Otherwise the user will only see a blank page.
1 parent a6065df commit 2d3f6dc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/commands/serve.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,25 @@ impl ServeCommand {
445445
Ok(r) => Ok::<_, Infallible>(r),
446446
Err(e) => {
447447
eprintln!("error: {e:?}");
448+
let error_html = "\
449+
<!doctype html>
450+
<html>
451+
<head>
452+
<title>500 Internal Server Error</title>
453+
</head>
454+
<body>
455+
<center>
456+
<h1>500 Internal Server Error</h1>
457+
<hr>
458+
wasmtime
459+
</center>
460+
</body>
461+
</html>";
448462
Ok(Response::builder()
449463
.status(StatusCode::INTERNAL_SERVER_ERROR)
464+
.header("Content-Type", "text/html; charset=UTF-8")
450465
.body(
451-
Full::new(bytes::Bytes::new())
466+
Full::new(bytes::Bytes::from(error_html))
452467
.map_err(to_errorcode)
453468
.boxed(),
454469
)

0 commit comments

Comments
 (0)