@app.errorhandler(500)
def error_500_handler(error):
 new_issue = 'https://github.com/andresriancho/w3af/issues/new'
 try:
  (exc_type, exc_value, exc_traceback) = sys.exc_info()
  filepath = traceback.extract_tb(exc_traceback)[(-1)][0]
  filename = basename(filepath)
  (lineno, function_name) = get_last_call_info(exc_traceback)
  response = jsonify({'code': 500, 'message': str(error), 'filename': filename, 'line_number': lineno, 'function_name': function_name, 'exception_type': error.__class__.__name__, 'please': new_issue})
 except Exception as e:
  response = jsonify({'code': 500, 'exception': str(error), 'handler_exception': str(e), 'please': new_issue, 'message': 'REST API error'})
 response.status_code = 500
 return response

@ app . errorhandler ( 500 ) def error_500_handler ( error ) : new_issue = 'https://github.com/andresriancho/w3af/issues/new' try : ( exc_type , exc_value , exc_traceback ) = sys . exc_info ( ) filepath = traceback . extract_tb ( exc_traceback ) [ ( - 1 ) ] [ 0 ] filename = basename ( filepath ) ( lineno , function_name ) = get_last_call_info ( exc_traceback ) response = jsonify ( { 'code' : 500 , 'message' : str ( error ) , 'filename' : filename , 'line_number' : lineno , 'function_name' : function_name , 'exception_type' : error . __class__ . __name__ , 'please' : new_issue } ) except Exception as e : response = jsonify ( { 'code' : 500 , 'exception' : str ( error ) , 'handler_exception' : str ( e ) , 'please' : new_issue , 'message' : 'REST API error' } ) response . status_code = 500 return response
this error handler will catch all unhandled exceptions in the w3af rest api and return something useful to the user for debugging .