mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 07:50:24 +08:00
Improve request error debug output
This commit is contained in:
parent
835e9e5d86
commit
396de53322
@ -206,7 +206,7 @@ export default class App {
|
||||
try {
|
||||
return JSON.parse(responseText);
|
||||
} catch (e) {
|
||||
throw new RequestError(500, responseText);
|
||||
throw new RequestError(500, responseText, options, xhr);
|
||||
}
|
||||
});
|
||||
|
||||
@ -230,7 +230,7 @@ export default class App {
|
||||
const status = xhr.status;
|
||||
|
||||
if (status < 200 || status > 299) {
|
||||
throw new RequestError(status, responseText, xhr);
|
||||
throw new RequestError(status, responseText, options, xhr);
|
||||
}
|
||||
|
||||
return responseText;
|
||||
|
@ -5,6 +5,12 @@ export default class RequestErrorModal extends Modal {
|
||||
return 'RequestErrorModal Modal--large';
|
||||
}
|
||||
|
||||
title() {
|
||||
return this.props.error.xhr
|
||||
? this.props.error.xhr.status+' '+this.props.error.xhr.statusText
|
||||
: '';
|
||||
}
|
||||
|
||||
content() {
|
||||
let responseText;
|
||||
|
||||
@ -15,7 +21,10 @@ export default class RequestErrorModal extends Modal {
|
||||
}
|
||||
|
||||
return <div className="Modal-body">
|
||||
<pre>{responseText}</pre>
|
||||
<pre>
|
||||
{this.props.error.options.method} {this.props.error.options.url}<br/><br/>
|
||||
{responseText}
|
||||
</pre>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
export default class RequestError {
|
||||
constructor(status, responseText, xhr) {
|
||||
constructor(status, responseText, options, xhr) {
|
||||
this.status = status;
|
||||
this.responseText = responseText;
|
||||
this.options = options;
|
||||
this.xhr = xhr;
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user