mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:16:01 +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
16 lines
304 B
JavaScript
16 lines
304 B
JavaScript
export default class RequestError {
|
|
constructor(status, responseText, xhr) {
|
|
this.status = status;
|
|
this.responseText = responseText;
|
|
this.xhr = xhr;
|
|
|
|
try {
|
|
this.response = JSON.parse(responseText);
|
|
} catch (e) {
|
|
this.response = null;
|
|
}
|
|
|
|
this.alert = null;
|
|
}
|
|
}
|