show error, don't crash
This commit is contained in:
parent
ff047efd85
commit
305c26c215
1 changed files with 2 additions and 2 deletions
|
@ -105,15 +105,15 @@ public class LabyrinthServer {
|
|||
exchange.sendResponseHeaders(302, -1);
|
||||
return;
|
||||
}
|
||||
final Labyrinth labyrinth = new Labyrinth(width, height, id);
|
||||
final byte[] render;
|
||||
try {
|
||||
final Labyrinth labyrinth = new Labyrinth(width, height, id);
|
||||
render = output.render(labyrinth);
|
||||
} catch (Exception e) {
|
||||
responseHeaders.add("Content-type", "text/plain; charset=UTF-8");
|
||||
exchange.sendResponseHeaders(500, 0);
|
||||
final OutputStream responseBody = exchange.getResponseBody();
|
||||
responseBody.write(("Error: " + e).getBytes(StandardCharsets.UTF_8));
|
||||
responseBody.write(("Error: " + e.getMessage()).getBytes(StandardCharsets.UTF_8));
|
||||
responseBody.flush();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue