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