Commit 187cef14 authored by Jérome Perrin's avatar Jérome Perrin

Display a traceback in the GUI in case of errors

From George idea
parent 29773939
import json
import traceback
from pprint import pformat
from flask import Flask, jsonify, redirect, url_for
from flask import request
......@@ -15,7 +16,12 @@ def front_page():
def runSimulation():
parameter_dict = request.json['json']
app.logger.debug("running with:\n%s" % (pformat(parameter_dict,)))
return jsonify(json.loads(simulate_line_json(input_data=json.dumps(parameter_dict))))
try:
result = simulate_line_json(input_data=json.dumps(parameter_dict))
return jsonify(dict(success=json.loads(result)))
except Exception, e:
tb = traceback.format_exc()
return jsonify(dict(error=e.args[0], traceback=tb))
def main(*args):
app.run(debug=True)
......
......@@ -127,12 +127,16 @@
function(e){
dream_instance.runSimulation(
function(data) {
$("#json_result").text(JSON.stringify(data, undefined, " "));
$.each(data.coreObject, function(idx, obj){
var e = $("#" + obj.id);
/* attach something to each corresponding core object */
// e.tooltip(JSON.stringify(obj['results'], undefined, " "));
})
if (data['success']) {
$("#json_result").text(JSON.stringify(data['success'], undefined, " "));
$.each(data.coreObject, function(idx, obj){
var e = $("#" + obj.id);
/* attach something to each corresponding core object */
// e.tooltip(JSON.stringify(obj['results'], undefined, " "));
})
} else {
$("#json_result").effect('shake', 50).text(data['traceback']);
}
});
e.preventDefault();
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment