From 88db3536fe679cd2adf24b833ae55826bbf62c4a Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 10 Nov 2023 01:52:39 +0100 Subject: [PATCH] Install some basic error handling in Dispatch. --- src/jrw/Dispatch.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/jrw/Dispatch.java b/src/jrw/Dispatch.java index 10b0909..894bbbf 100644 --- a/src/jrw/Dispatch.java +++ b/src/jrw/Dispatch.java @@ -1,6 +1,8 @@ package jrw; import java.util.*; +import java.io.*; +import jrw.resp.*; public class Dispatch { public static Map handle(Handler handler, Request req) { @@ -10,6 +12,9 @@ public class Dispatch { return(handler.handle(req)); } catch(Restart r) { handler = r; + } catch(Throwable t) { + t.printStackTrace((PrintStream)req.env.get("jagi.errors")); + handler = new jrw.resp.HttpError(500); } } } -- 2.11.0