Skip to content

Commit

Permalink
Improve error reporting for Ajax callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Quentel committed Nov 26, 2016
1 parent 6cf34ab commit f5fa46a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 16 additions & 1 deletion www/src/libs/_ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,22 @@ ajax.$dict = {

bind : function(self, evt, func){
// req.bind(evt,func) is the same as req.onevt = func
self.js['on'+evt] = func
self.js['on'+evt] = function(){
try{
return func.apply(null, arguments)
}catch(err){
if(err.__class__!==undefined){
var msg = _b_.getattr(err, 'info')+
'\n'+err.__class__.__name__
if(err.args){msg += ': '+err.args[0]}
try{getattr($B.stderr,"write")(msg)}
catch(err){console.log(msg)}
}else{
try{getattr($B.stderr,"write")(err)}
catch(err1){console.log(err)}
}
}
}
return $N
},

Expand Down
3 changes: 1 addition & 2 deletions www/src/py_exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,9 @@ $B.exception = function(js_exc){
// js_exc is the Javascript exception, which can be raised by the
// code generated by Python - in this case it has attribute $py_error set -
// or by the Javascript interpreter (ReferenceError for instance)

if(!js_exc.$py_error){
// Print complete Javascript traceback in console
//console.log(js_exc)
//console.log('js exc', js_exc)

if(js_exc.info===undefined){
var _frame = $B.last($B.frames_stack)
Expand Down

0 comments on commit f5fa46a

Please sign in to comment.