X-Git-Url: http://git.hcoop.net/bpt/mlt.git/blobdiff_plain/8291a2b90d90a19fe92cd2ee8d71b62efad58ba3..b26ce3d96429d8721e85500d48d7dab2f97688e5:/src/lib/main.sml
diff --git a/src/lib/main.sml b/src/lib/main.sml
index b058cce..157afaa 100644
--- a/src/lib/main.sml
+++ b/src/lib/main.sml
@@ -30,6 +30,7 @@ struct
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
500 error500 error
No template was specified\n";
OS.Process.failure)
@@ -38,12 +39,16 @@ 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 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