Commit 3aef85e17bc4c3e1809cabcc4a17529bd8fd65e5

Authored by Antoine Goutenoir
1 parent 6939099a
Exists in master

feat: improve error reporting when not in production env

Showing 1 changed file with 7 additions and 4 deletions   Show diff stats
flaskr/controllers/main_controller.py
1 import csv 1 import csv
2 import re 2 import re
3 -# from io import StringIO  
4 -from cStringIO import StringIO 3 +# from cStringIO import StringIO
5 from copy import deepcopy 4 from copy import deepcopy
6 -from os import unlink 5 +from io import StringIO
  6 +from os import unlink, getenv
7 from os.path import join 7 from os.path import join
8 8
9 import geopy 9 import geopy
@@ -13,6 +13,7 @@ from flask import ( @@ -13,6 +13,7 @@ from flask import (
13 Blueprint, 13 Blueprint,
14 Response, 14 Response,
15 render_template, 15 render_template,
  16 + request,
16 flash, 17 flash,
17 redirect, 18 redirect,
18 url_for, 19 url_for,
@@ -699,7 +700,9 @@ def compute(): # process the queue of estimation requests @@ -699,7 +700,9 @@ def compute(): # process the queue of estimation requests
699 700
700 except Exception as e: 701 except Exception as e:
701 errmsg = u"Computation failed : %s" % (e,) 702 errmsg = u"Computation failed : %s" % (e,)
702 - # errmsg = u"%s\n\n%s" % (errmsg, traceback.format_exc()) 703 + if 'production' != getenv('FLASK_ENV', 'production'):
  704 + import traceback
  705 + errmsg = u"%s\n\n%s" % (errmsg, traceback.format_exc())
703 if estimation: 706 if estimation:
704 _handle_failure(estimation, errmsg) 707 _handle_failure(estimation, errmsg)
705 return _respond(errmsg) 708 return _respond(errmsg)