@@ -159,21 +159,28 @@ $(document).ready(function() {
159159 function ( traceData ) {
160160 // don't enter visualize mode if there are killer errors:
161161 if ( ! traceData ||
162+ ( traceData . length == 0 ) ||
162163 ( ( traceData . length == 1 ) && traceData [ 0 ] . event == 'uncaught_exception' ) ) {
163- var errorLineNo = traceData [ 0 ] . line - 1 ; /* CodeMirror lines are zero-indexed */
164- if ( errorLineNo !== undefined ) {
165- // highlight the faulting line in pyInputCodeMirror
166- pyInputCodeMirror . focus ( ) ;
167- pyInputCodeMirror . setCursor ( errorLineNo , 0 ) ;
168- pyInputCodeMirror . setLineClass ( errorLineNo , null , 'errorLine' ) ;
169-
170- pyInputCodeMirror . setOption ( 'onChange' , function ( ) {
171- pyInputCodeMirror . setLineClass ( errorLineNo , null , null ) ; // reset line back to normal
172- pyInputCodeMirror . setOption ( 'onChange' , null ) ; // cancel
173- } ) ;
174- }
175164
176- alert ( traceData [ 0 ] . exception_msg ) ;
165+ if ( traceData . length > 0 ) {
166+ var errorLineNo = traceData [ 0 ] . line - 1 ; /* CodeMirror lines are zero-indexed */
167+ if ( errorLineNo !== undefined ) {
168+ // highlight the faulting line in pyInputCodeMirror
169+ pyInputCodeMirror . focus ( ) ;
170+ pyInputCodeMirror . setCursor ( errorLineNo , 0 ) ;
171+ pyInputCodeMirror . setLineClass ( errorLineNo , null , 'errorLine' ) ;
172+
173+ pyInputCodeMirror . setOption ( 'onChange' , function ( ) {
174+ pyInputCodeMirror . setLineClass ( errorLineNo , null , null ) ; // reset line back to normal
175+ pyInputCodeMirror . setOption ( 'onChange' , null ) ; // cancel
176+ } ) ;
177+ }
178+
179+ alert ( traceData [ 0 ] . exception_msg ) ;
180+ }
181+ else {
182+ alert ( "Whoa, unknown error! Please reload and try again." ) ;
183+ }
177184
178185 $ ( '#executeBtn' ) . html ( "Visualize execution" ) ;
179186 $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
0 commit comments