Skip to content

Commit bfb7cdb

Browse files
committed
ServerUtils: handle exceptions
1 parent 96e8a04 commit bfb7cdb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

requests/test/src/requests/ServerUtils.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object ServerUtils {
2525

2626
def stop(): Unit = server.stop(0)
2727

28-
override def handle(t: HttpExchange): Unit = {
28+
override def handle(t: HttpExchange): Unit = try {
2929
val h: java.util.List[String] =
3030
t.getRequestHeaders.get("Content-encoding")
3131
val c: Compress =
@@ -36,6 +36,10 @@ object ServerUtils {
3636
val msg = new Plumper(c).decompress(t.getRequestBody)
3737
t.sendResponseHeaders(200, msg.length)
3838
t.getResponseBody.write(msg.getBytes())
39+
} catch {
40+
case e: Exception =>
41+
e.printStackTrace()
42+
t.sendResponseHeaders(500, -1)
3943
}
4044
}
4145

0 commit comments

Comments
 (0)