Install some basic error handling in Dispatch. master
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 10 Nov 2023 00:52:39 +0000 (01:52 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 10 Nov 2023 00:52:39 +0000 (01:52 +0100)
src/jrw/Dispatch.java

index 10b0909..894bbbf 100644 (file)
@@ -1,6 +1,8 @@
 package jrw;
 
 import java.util.*;
 package jrw;
 
 import java.util.*;
+import java.io.*;
+import jrw.resp.*;
 
 public class Dispatch {
     public static Map<Object, Object> handle(Handler handler, Request req) {
 
 public class Dispatch {
     public static Map<Object, Object> handle(Handler handler, Request req) {
@@ -10,6 +12,9 @@ public class Dispatch {
                    return(handler.handle(req));
                } catch(Restart r) {
                    handler = r;
                    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);
                }
            }
        }
                }
            }
        }