@@ -102,6 +102,15 @@ function redrawConnectors() {
102102 }
103103}
104104
105+ function setFronendError ( lines ) {
106+ $ ( "#frontendErrorOutput" ) . html ( lines . map ( htmlspecialchars ) . join ( '<br/>' ) ) ;
107+ $ ( "#frontendErrorOutput" ) . show ( ) ;
108+ }
109+
110+ function clearFrontendError ( ) {
111+ $ ( "#frontendErrorOutput" ) . hide ( ) ;
112+ }
113+
105114
106115// run at the END so that everything else can be initialized first
107116function genericOptFrontendReady ( ) {
@@ -153,12 +162,14 @@ function genericOptFrontendReady() {
153162 return ; // get out early
154163 }
155164
156- alert ( "Server error (possibly due to memory/resource overload). " +
157- "Report a bug to philip@pgbovine.net\n\n" +
158- "(Click the 'Generate URL' button to include a unique URL in your email bug report.)" ) ;
165+ setFronendError ( [ "Server error (possibly due to memory/resource overload)." ,
166+ "Report a bug to philip@pgbovine.net by clicking on the" ,
167+ " 'Generate URL' button and including a URL in your email." ] ) ;
159168
160169 doneExecutingCode ( ) ;
161170 } ) ;
171+
172+ clearFrontendError ( ) ;
162173}
163174
164175function getQueryStringOptions ( ) {
@@ -370,12 +381,16 @@ function executePythonCode(pythonSourceCode,
370381 outputDiv ,
371382 handleSuccessFunc , handleUncaughtExceptionFunc ) {
372383 if ( ! backendScript ) {
373- alert ( 'Server configuration error: No backend script' ) ;
384+ setFronendError ( [ "Server configuration error: No backend script" ,
385+ "Report a bug to philip@pgbovine.net by clicking on the" ,
386+ "'Generate URL' button and including a URL in your email." ] ) ;
374387 return ;
375388 }
376389
377390 isExecutingCode = true ; // nasty global
378391
392+ clearFrontendError ( ) ;
393+
379394 $ . get ( backendScript ,
380395 { user_script : pythonSourceCode ,
381396 raw_input_json : rawInputLst . length > 0 ? JSON . stringify ( rawInputLst ) : '' ,
@@ -391,16 +406,15 @@ function executePythonCode(pythonSourceCode,
391406 handleUncaughtExceptionFunc ( trace ) ;
392407
393408 if ( trace . length == 1 ) {
394- alert ( trace [ 0 ] . exception_msg ) ;
409+ setFronendError ( [ trace [ 0 ] . exception_msg ] ) ;
395410 }
396411 else if ( trace [ trace . length - 1 ] . exception_msg ) {
397- alert ( trace [ trace . length - 1 ] . exception_msg ) ;
412+ setFronendError ( [ trace [ trace . length - 1 ] . exception_msg ] ) ;
398413 }
399414 else {
400- alert ( "Unknown error. Reload to try again," +
401- "or report a bug to philip@pgbovine.net\n\n" +
402- "(Click the 'Generate URL' button to include a " +
403- "unique URL in your email bug report.)" ) ;
415+ setFronendError ( [ "Unknown error. Reload the page and try again." ,
416+ "Report a bug to philip@pgbovine.net by clicking on the" ,
417+ "'Generate URL' button and including a URL in your email." ] ) ;
404418 }
405419 }
406420 else {
0 commit comments