summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-07-03 12:40:00 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-07-03 12:40:00 -0400
commit3311911fd21e0c240788d83ff6da710dbbbc66e8 (patch)
tree57875f0e93a279eeaac3f66eac6372405cdf4b60
parentdd592cc205438ef4a46f7103d0fc7113e376d358 (diff)
For non-debug builds, leave out source location info in what is shown to user
-rw-r--r--include/urweb.h2
-rw-r--r--src/c/urweb.c10
-rw-r--r--src/cjr_print.sml5
-rw-r--r--src/compiler.sml3
-rw-r--r--tests/error.ur5
-rw-r--r--tests/error.urp5
6 files changed, 21 insertions, 9 deletions
diff --git a/include/urweb.h b/include/urweb.h
index 4c1489c9..240623ee 100644
--- a/include/urweb.h
+++ b/include/urweb.h
@@ -340,4 +340,6 @@ uw_Basis_time *uw_Basis_readUtc(uw_context, uw_Basis_string);
void uw_isPost(uw_context);
uw_Basis_bool uw_Basis_currentUrlHasPost(uw_context);
+void uw_cutErrorLocation(char *);
+
#endif
diff --git a/src/c/urweb.c b/src/c/urweb.c
index b653390a..e38cd072 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3894,3 +3894,13 @@ failure_kind uw_begin_onError(uw_context ctx, char *msg) {
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);
+}
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 9b747bcb..79d7e7da 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -3112,6 +3112,11 @@ fun p_file env (ds, ps) =
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));",
diff --git a/src/compiler.sml b/src/compiler.sml
index 229b40ff..d4f34021 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -324,7 +324,8 @@ fun capitalize "" = ""
| 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);
diff --git a/tests/error.ur b/tests/error.ur
index e5586d8d..00c0105f 100644
--- a/tests/error.ur
+++ b/tests/error.ur
@@ -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>
diff --git a/tests/error.urp b/tests/error.urp
deleted file mode 100644
index d6579653..00000000
--- a/tests/error.urp
+++ /dev/null
@@ -1,5 +0,0 @@
-debug
-database dbname=test
-exe /tmp/webapp
-
-error