mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
Improving Presto error message in explore/dashboard (#2633)
* Improving Presto error message in explore/dashboard * lint
This commit is contained in:
parent
ac51a30f98
commit
cb3384b3b2
@ -57,7 +57,7 @@ export default class DisplayQueryButton extends React.PureComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
beforeOpen() {
|
beforeOpen() {
|
||||||
if (this.props.chartStatus === 'loading' || this.props.chartStatus === null) {
|
if (['loading', null].indexOf(this.props.chartStatus) >= 0 || !this.props.queryResponse) {
|
||||||
this.fetchQuery();
|
this.fetchQuery();
|
||||||
} else {
|
} else {
|
||||||
this.setStateFromQueryResponse();
|
this.setStateFromQueryResponse();
|
||||||
@ -72,11 +72,13 @@ export default class DisplayQueryButton extends React.PureComponent {
|
|||||||
/>);
|
/>);
|
||||||
} else if (this.state.error) {
|
} else if (this.state.error) {
|
||||||
return <pre>{this.state.error}</pre>;
|
return <pre>{this.state.error}</pre>;
|
||||||
|
} else if (this.state.query) {
|
||||||
|
return (
|
||||||
|
<SyntaxHighlighter language={this.state.language} style={github}>
|
||||||
|
{this.state.query}
|
||||||
|
</SyntaxHighlighter>);
|
||||||
}
|
}
|
||||||
return (
|
return null;
|
||||||
<SyntaxHighlighter language={this.state.language} style={github}>
|
|
||||||
{this.state.query}
|
|
||||||
</SyntaxHighlighter>);
|
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
@ -547,7 +547,8 @@ class SqlaTable(Model, BaseDatasource):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
status = QueryStatus.FAILED
|
status = QueryStatus.FAILED
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
error_message = str(e)
|
error_message = (
|
||||||
|
self.database.db_engine_spec.extract_error_message(e))
|
||||||
|
|
||||||
return QueryResult(
|
return QueryResult(
|
||||||
status=status,
|
status=status,
|
||||||
|
@ -484,11 +484,12 @@ class PrestoEngineSpec(BaseEngineSpec):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def extract_error_message(cls, e):
|
def extract_error_message(cls, e):
|
||||||
if hasattr(e, 'orig') \
|
if (
|
||||||
and type(e.orig).__name__ == 'DatabaseError' \
|
hasattr(e, 'orig') and
|
||||||
and isinstance(e.orig[0], dict):
|
type(e.orig).__name__ == 'DatabaseError' and
|
||||||
|
isinstance(e.orig[0], dict)):
|
||||||
error_dict = e.orig[0]
|
error_dict = e.orig[0]
|
||||||
e = '{} at {}: {}'.format(
|
return '{} at {}: {}'.format(
|
||||||
error_dict['errorName'],
|
error_dict['errorName'],
|
||||||
error_dict['errorLocation'],
|
error_dict['errorLocation'],
|
||||||
error_dict['message']
|
error_dict['message']
|
||||||
|
Loading…
Reference in New Issue
Block a user