changeset 1483:ebc30bb262d0

For non-debug builds, leave out source location info in what is shown to user
author Adam Chlipala <adam@chlipala.net>
date Sun, 03 Jul 2011 12:40:00 -0400
parents 8314f1a309e7
children ae7547789c73
files include/urweb.h src/c/urweb.c src/cjr_print.sml src/compiler.sml tests/error.ur tests/error.urp
diffstat 6 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/include/urweb.h	Tue Jun 28 08:07:20 2011 -0400
+++ b/include/urweb.h	Sun Jul 03 12:40:00 2011 -0400
@@ -340,4 +340,6 @@
 void uw_isPost(uw_context);
 uw_Basis_bool uw_Basis_currentUrlHasPost(uw_context);
 
+void uw_cutErrorLocation(char *);
+
 #endif
--- a/src/c/urweb.c	Tue Jun 28 08:07:20 2011 -0400
+++ b/src/c/urweb.c	Sun Jul 03 12:40:00 2011 -0400
@@ -3894,3 +3894,13 @@
 void uw_mayReturnIndirectly(uw_context ctx) {
   ctx->allowed_to_return_indirectly = 1;
 }
+
+void uw_cutErrorLocation(char *s) {
+  char *s2;
+
+  s2 = strstr(s, ": ");
+  if (s2 == NULL || strcspn(s, "<&") < s2 - s)
+    return;
+
+  memmove(s, s2+2, strlen(s2+2)+1);
+}
--- a/src/cjr_print.sml	Tue Jun 28 08:07:20 2011 -0400
+++ b/src/cjr_print.sml	Sun Jul 03 12:40:00 2011 -0400
@@ -3112,6 +3112,11 @@
                  NONE => box []
                | SOME n => box [string "static void uw_onError(uw_context ctx, char *msg) {",
                                 newline,
+                                if Settings.getDebug () then
+                                    box []
+                                else
+                                    box [string "uw_cutErrorLocation(msg);",
+                                         newline],
                                 box [string "uw_write(ctx, ",
                                      p_enamed env n,
                                      string "(ctx, msg, 0));",
--- a/src/compiler.sml	Tue Jun 28 08:07:20 2011 -0400
+++ b/src/compiler.sml	Sun Jul 03 12:40:00 2011 -0400
@@ -324,7 +324,8 @@
   | capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
 
 fun institutionalizeJob (job : job) =
-    (Settings.setUrlPrefix (#prefix job);
+    (Settings.setDebug (#debug job);
+     Settings.setUrlPrefix (#prefix job);
      Settings.setTimeout (#timeout job);
      Settings.setHeaders (#headers job);
      Settings.setScripts (#scripts job);
--- a/tests/error.ur	Tue Jun 28 08:07:20 2011 -0400
+++ b/tests/error.ur	Sun Jul 03 12:40:00 2011 -0400
@@ -1,3 +1,2 @@
-fun main () : transaction page = return <html><body>
-        <font size={error <body>I couldn't make up my <b>mind</b>!</body>}>Hello!</font>
-</body></html>
+fun main () : transaction page =
+  error <xml>I couldn't make up my <b>mind</b>!</xml>
--- a/tests/error.urp	Tue Jun 28 08:07:20 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-debug
-database dbname=test
-exe /tmp/webapp
-
-error