mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
Druid sometimes returns error message that are contained in "<>", as in `<urlopen error [Errno 61] Connection refused>`. Since Superset's approach is often to bubble up messages coming from external library, it's impossible to predict whether it will contain special characters. There are some cases where our error handling does return some html (presto?), but we should manage that upstream. Plus the current setup has security concerns, so let's move away from that.
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
/* eslint-disable react/no-danger */
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Alert, Collapse } from 'react-bootstrap';
|
|
|
|
const propTypes = {
|
|
message: PropTypes.string,
|
|
queryResponse: PropTypes.object,
|
|
showStackTrace: PropTypes.bool,
|
|
};
|
|
const defaultProps = {
|
|
showStackTrace: false,
|
|
};
|
|
|
|
class StackTraceMessage extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
showStackTrace: props.showStackTrace,
|
|
};
|
|
}
|
|
|
|
hasTrace() {
|
|
return this.props.queryResponse && this.props.queryResponse.stacktrace;
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className={`stack-trace-container${this.hasTrace() ? ' has-trace' : ''}`}>
|
|
<Alert
|
|
bsStyle="warning"
|
|
onClick={() => this.setState({ showStackTrace: !this.state.showStackTrace })}
|
|
>
|
|
{this.props.message}
|
|
</Alert>
|
|
{this.hasTrace() &&
|
|
<Collapse in={this.state.showStackTrace}>
|
|
<pre>
|
|
{this.props.queryResponse.stacktrace}
|
|
</pre>
|
|
</Collapse>
|
|
}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
StackTraceMessage.propTypes = propTypes;
|
|
StackTraceMessage.defaultProps = defaultProps;
|
|
|
|
export default StackTraceMessage;
|