fun mapper name = (name, Cgi.cgi_field_strings name)
in
Web.pushParams (map mapper cgiFields);
+ Templates.beforeFn ();
case args of
[] => (print "Status: 500\nContent-type: text/html\n\n<html><head><title>500 error</title></head><body><h2>500 error</h2>No template was specified</body></html>\n";
OS.Process.failure)
NONE => (print "Status: 404\nContent-type: text/html\n\n<html><head><title>404 error</title></head><body><h2>404 error</h2>Template not found</body></html>\n";
OS.Process.failure)
| SOME f => (f ();
+ Templates.afterFn ();
Web.output ();
OS.Process.success))
- end handle Fail msg => (print "Status: 500\nContent-type: text/plain\n\nFatal error: \n\n";
- print msg;
- OS.Process.failure)
- | ex => (print "Status: 500\nContent-type: text/plain\n\nAn exception!\n\n";
- app (fn s => print (s ^ "\n")) (SMLofNJ.exnHistory ex);
+ end handle ex => (Web.setExn ex;
+ Web.clear ();
+ Templates.exnFn ();
+ if Web.noOutput () then
+ (print "Status: 500\nContent-type: text/plain\n\nAn exception!\n\n";
+ app (fn s => print (s ^ "\n")) (SMLofNJ.exnHistory ex))
+ else
+ Web.output ();
OS.Process.failure)
end
\ No newline at end of file