X-Git-Url: http://git.hcoop.net/bpt/mlt.git/blobdiff_plain/c0a3b4882df1afe4a0155654c1102bd0f9729993..4e62d6ab7d49de0727b085f93575eadddd063ba8:/src/lib/main.sml
diff --git a/src/lib/main.sml b/src/lib/main.sml
index 0533912..9ffaf5c 100644
--- a/src/lib/main.sml
+++ b/src/lib/main.sml
@@ -27,9 +27,11 @@ struct
let
val _ = Cgi.init ()
val cgiFields = Cgi.cgi_fieldnames ()
- fun mapper name = (name, valOf (Cgi.cgi_field_string name))
+ fun mapper name = (name, Cgi.cgi_field_strings name)
in
+ Web.addHeader ("Content-type", "text/html");
Web.pushParams (map mapper cgiFields);
+ Templates.beforeFn ();
case args of
[] => (print "Status: 500\nContent-type: text/html\n\n
500 error500 error
No template was specified\n";
OS.Process.failure)
@@ -38,9 +40,20 @@ struct
NONE => (print "Status: 404\nContent-type: text/html\n\n404 error404 error
Template not found\n";
OS.Process.failure)
| SOME f => (f ();
+ Templates.afterFn ();
Web.output ();
OS.Process.success))
- end handle 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\nUncaught exception:\n\n";
+ app (fn s => print (s ^ "\n")) (SMLofNJ.exnHistory ex))
+ else
+ Web.output ())
+ handle ex' => (print "Status: 500\nContent-type : text/plain\n\nUncaught exception:\n\n";
+ app (fn s => print ("\t" ^ s ^ "\n")) (SMLofNJ.exnHistory ex);
+ print "\nAnother exception raised in exception handler:\n\n";
+ app (fn s => print ("\t" ^ s ^ "\n")) (SMLofNJ.exnHistory ex'));
OS.Process.failure)
end
\ No newline at end of file