mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-28 02:00:57 +00:00
Handle JS exceptions in API error logging
When an exception is thrown by our code elsewhere, and caught by the promise mechanisms, it bubbles up here in the `code` variable, and `data` is undefined. Change-Id: I8a0ac49d22d254f353797fc8978871502ae8b9de
This commit is contained in:
parent
6cb595296f
commit
d0f8794388
|
@ -831,11 +831,16 @@ ReplyWidget.prototype.onReplyClick = function () {
|
||||||
widget.errorMessage.$element.insertBefore( widget.replyBodyWidget.$element );
|
widget.errorMessage.$element.insertBefore( widget.replyBodyWidget.$element );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( code instanceof Error ) {
|
||||||
|
code = 'exception';
|
||||||
|
}
|
||||||
// Log more precise error codes, mw.Api just gives us 'http' in all of these cases
|
// Log more precise error codes, mw.Api just gives us 'http' in all of these cases
|
||||||
if ( data.textStatus === 'timeout' || data.textStatus === 'abort' || data.textStatus === 'parsererror' ) {
|
if ( data ) {
|
||||||
code = data.textStatus;
|
if ( data.textStatus === 'timeout' || data.textStatus === 'abort' || data.textStatus === 'parsererror' ) {
|
||||||
} else if ( data.xhr ) {
|
code = data.textStatus;
|
||||||
code = 'http-' + ( data.xhr.status || 0 );
|
} else if ( data.xhr ) {
|
||||||
|
code = 'http-' + ( data.xhr.status || 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger( {
|
logger( {
|
||||||
|
|
Loading…
Reference in a new issue