Skip to content

Commit

Permalink
Improving Presto error message in explore/dashboard (#2633)
Browse files Browse the repository at this point in the history
* Improving Presto error message in explore/dashboard

* lint
  • Loading branch information
mistercrunch authored Apr 18, 2017
1 parent ac51a30 commit cb3384b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class DisplayQueryButton extends React.PureComponent {
});
}
beforeOpen() {
if (this.props.chartStatus === 'loading' || this.props.chartStatus === null) {
if (['loading', null].indexOf(this.props.chartStatus) >= 0 || !this.props.queryResponse) {
this.fetchQuery();
} else {
this.setStateFromQueryResponse();
Expand All @@ -72,11 +72,13 @@ export default class DisplayQueryButton extends React.PureComponent {
/>);
} else if (this.state.error) {
return <pre>{this.state.error}</pre>;
} else if (this.state.query) {
return (
<SyntaxHighlighter language={this.state.language} style={github}>
{this.state.query}
</SyntaxHighlighter>);
}
return (
<SyntaxHighlighter language={this.state.language} style={github}>
{this.state.query}
</SyntaxHighlighter>);
return null;
}
render() {
return (
Expand Down
3 changes: 2 additions & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ def query(self, query_obj):
except Exception as e:
status = QueryStatus.FAILED
logging.exception(e)
error_message = str(e)
error_message = (
self.database.db_engine_spec.extract_error_message(e))

return QueryResult(
status=status,
Expand Down
9 changes: 5 additions & 4 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,12 @@ def handle_cursor(cls, cursor, query, session):

@classmethod
def extract_error_message(cls, e):
if hasattr(e, 'orig') \
and type(e.orig).__name__ == 'DatabaseError' \
and isinstance(e.orig[0], dict):
if (
hasattr(e, 'orig') and
type(e.orig).__name__ == 'DatabaseError' and
isinstance(e.orig[0], dict)):
error_dict = e.orig[0]
e = '{} at {}: {}'.format(
return '{} at {}: {}'.format(
error_dict['errorName'],
error_dict['errorLocation'],
error_dict['message']
Expand Down

0 comments on commit cb3384b

Please sign in to comment.