# HG changeset patch # User Adam Chlipala # Date 1335628835 14400 # Node ID 27e731a659349d73df5dd5ca6f40ce326a09fa9c # Parent 02533f681ad2752dd58fac1a67131d05966a2e53 Include JavaScript files properly in error handler pages diff -r 02533f681ad2 -r 27e731a65934 src/cjr_print.sml --- a/src/cjr_print.sml Sat Apr 28 11:35:12 2012 -0400 +++ b/src/cjr_print.sml Sat Apr 28 12:00:35 2012 -0400 @@ -2905,6 +2905,19 @@ val app_js = OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), file = "app." ^ timestamp ^ ".js"} + val allScripts = + let + val scripts = + "\\n" + in + foldl (fn (x, scripts) => + scripts + ^ "\\n") + scripts (Settings.getScripts ()) + end + fun p_page (ek, s, n, ts, ran, side, tellSig) = let val (ts, defInputs, inputsVar, fields) = @@ -3032,18 +3045,7 @@ val scripts = case side of ServerOnly => "" - | _ => - let - val scripts = - "\\n" - in - foldl (fn (x, scripts) => - scripts - ^ "\\n") - scripts (Settings.getScripts ()) - end + | _ => allScripts in string scripts end, @@ -3129,6 +3131,7 @@ val expunge = ref 0 val initialize = ref 0 val prepped = ref [] + val hasJs = ref false val _ = foldl (fn (d, env) => ((case #1 d of @@ -3136,6 +3139,7 @@ dbstring := x; expunge := y; initialize := z) + | DJavaScript _ => hasJs := true | DTable (s, xts, _, _) => tables := (s, map (fn (x, t) => (x, sql_type_in env t)) xts) :: !tables | DView (s, xts, _) => views := (s, map (fn (x, t) => @@ -3499,6 +3503,13 @@ else box [string "uw_cutErrorLocation(msg);", newline], + if !hasJs then + box [string "uw_set_script_header(ctx, \"", + string allScripts, + string "\");", + newline] + else + box [], box [string "uw_write(ctx, ", p_enamed env n, string "(ctx, msg, 0));", diff -r 02533f681ad2 -r 27e731a65934 tests/onerrorJs.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/onerrorJs.ur Sat Apr 28 12:00:35 2012 -0400 @@ -0,0 +1,4 @@ +fun main n = + case n of + 0 => error Zero is bad!