Some more error handling when rendering the explore view (#361)

This commit is contained in:
Maxime Beauchemin 2016-04-15 15:00:49 -07:00
parent 01c2c7baf8
commit 04d769ff24
2 changed files with 11 additions and 5 deletions

View File

@ -112,11 +112,13 @@ class FormFactory(object):
from caravel.viz import viz_types
viz = self.viz
datasource = viz.datasource
if not datasource.metrics_combo:
raise Exception("Please define at least one metric for your table")
default_metric = datasource.metrics_combo[0][0]
gb_cols = datasource.groupby_column_names
default_groupby = gb_cols[0] if gb_cols else None
group_by_choices = [(s, s) for s in datasource.groupby_column_names]
group_by_choices = self.choicify(gb_cols)
# Pool of all the fields that can be used in Caravel
self.field_dict = {
'viz_type': SelectField(

View File

@ -490,10 +490,14 @@ class Caravel(BaseView):
return redirect(datasource.default_endpoint)
if not viz_type:
viz_type = "table"
obj = viz.viz_types[viz_type](
datasource,
form_data=request.args,
slice_=slc)
try:
obj = viz.viz_types[viz_type](
datasource,
form_data=request.args,
slice_=slc)
except Exception as e:
flash(str(e), "danger")
return redirect(error_redirect)
if request.args.get("json") == "true":
status = 200
try: