Added basic HTML generation and response handling.
[jrw.git] / src / jrw / resp / HttpError.java
diff --git a/src/jrw/resp/HttpError.java b/src/jrw/resp/HttpError.java
new file mode 100644 (file)
index 0000000..0593f5a
--- /dev/null
@@ -0,0 +1,26 @@
+package jrw.resp;
+
+import jrw.*;
+import jrw.sp.*;
+import jrw.util.*;
+import java.util.*;
+
+public class HttpError extends UserError {
+    public int code;
+
+    public HttpError(int code, String title, Object detail) {
+       super(title, detail);
+       this.code = code;
+    }
+    public HttpError(int code, Object detail) {
+       this(code, Http.statusinfo.get(code).status, detail);
+    }
+    public HttpError(int code) {
+       this(code, Http.statusinfo.get(code).message);
+    }
+
+    public Map<Object, Object> handle(Request req) {
+       req.status(code + " " + skel.title);
+       return(super.handle(req));
+    }
+}