From 305c26c21524264c4a0cc4437d17d01d873d712b Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 1 Apr 2023 00:21:38 +0200 Subject: [PATCH] show error, don't crash --- .../java/ch/fritteli/labyrinth/server/LabyrinthServer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java index 689d9bc..aab20f6 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java +++ b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java @@ -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; }