Skip to content

Commit

Permalink
[hotfix] explore errors are not raise properly 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Oct 13, 2016
1 parent 4e9392d commit 89cb726
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,18 +1192,29 @@ def slice(self, slice_id):
@has_access_api
@expose("/explore_json/<datasource_type>/<datasource_id>/")
def explore_json(self, datasource_type, datasource_id):
viz_obj = self.get_viz(
datasource_type=datasource_type,
datasource_id=datasource_id,
args=request.args)
try:
viz_obj = self.get_viz(
datasource_type=datasource_type,
datasource_id=datasource_id,
args=request.args)
except Exception as e:
return json_error_response(utils.error_msg_from_exception(e))

if not self.datasource_access(viz_obj.datasource):
return Response(
json.dumps(
{'error': _("You don't have access to this datasource")}),
status=404,
mimetype="application/json")

payload = ""
try:
payload = viz_obj.get_json()
except Exception as e:
return json_error_response(utils.error_msg_from_exception(e))

return Response(
viz_obj.get_json(),
payload,
status=200,
mimetype="application/json")

Expand Down

0 comments on commit 89cb726

Please sign in to comment.