mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 08:13:39 +08:00
26a821e3e2
The default XHR error handler produce an alert which is appropriate to the response status code. It can be overridden per-request (by specifying the `errorHandler` option) so that the alert can be suppressed or displayed in a different position (e.g. inside a modal). ref #118
22 lines
470 B
JavaScript
22 lines
470 B
JavaScript
import Modal from 'flarum/components/Modal';
|
|
|
|
export default class RequestErrorModal extends Modal {
|
|
className() {
|
|
return 'RequestErrorModal Modal--large';
|
|
}
|
|
|
|
content() {
|
|
let responseText;
|
|
|
|
try {
|
|
responseText = JSON.stringify(JSON.parse(this.props.error.responseText), null, 2);
|
|
} catch (e) {
|
|
responseText = this.props.error.responseText;
|
|
}
|
|
|
|
return <div className="Modal-body">
|
|
<pre>{responseText}</pre>
|
|
</div>;
|
|
}
|
|
}
|