Skip to content

Commit

Permalink
Some more error handling when rendering the explore view
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2016
1 parent 2d420ee commit 683d4df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion caravel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ def __init__(self, viz):
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(
Expand Down
12 changes: 8 additions & 4 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,14 @@ def explore(self, datasource_type, datasource_id):
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:
Expand Down

0 comments on commit 683d4df

Please sign in to comment.