Commit 80fd4654a289a9b85b332bc519bbfc40d73998ee

Authored by Antoine Goutenoir
1 parent 2b4cf2a1
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 1 import csv
2 2 import re
3   -# from io import StringIO
4   -from cStringIO import StringIO
  3 +# from cStringIO import StringIO
5 4 from copy import deepcopy
6   -from os import unlink
  5 +from io import StringIO
  6 +from os import unlink, getenv
7 7 from os.path import join
8 8  
9 9 import geopy
... ... @@ -13,6 +13,7 @@ from flask import (
13 13 Blueprint,
14 14 Response,
15 15 render_template,
  16 + request,
16 17 flash,
17 18 redirect,
18 19 url_for,
... ... @@ -699,7 +700,9 @@ def compute(): # process the queue of estimation requests
699 700  
700 701 except Exception as e:
701 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 706 if estimation:
704 707 _handle_failure(estimation, errmsg)
705 708 return _respond(errmsg)
... ...