# HG changeset patch # User Adam Chlipala # Date 1309711200 14400 # Node ID ebc30bb262d00c768c5687e0f114cdf9765b770b # Parent 8314f1a309e7599cae9178a2e2008249aea9fa53 For non-debug builds, leave out source location info in what is shown to user diff -r 8314f1a309e7 -r ebc30bb262d0 include/urweb.h --- 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 diff -r 8314f1a309e7 -r ebc30bb262d0 src/c/urweb.c --- 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); +} diff -r 8314f1a309e7 -r ebc30bb262d0 src/cjr_print.sml --- 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));", diff -r 8314f1a309e7 -r ebc30bb262d0 src/compiler.sml --- 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); diff -r 8314f1a309e7 -r ebc30bb262d0 tests/error.ur --- 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 - I couldn't make up my mind!}>Hello! - +fun main () : transaction page = + error I couldn't make up my mind! diff -r 8314f1a309e7 -r ebc30bb262d0 tests/error.urp --- 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