mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-30 19:16:39 +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,12 +831,17 @@ 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 ) {
|
||||||
if ( data.textStatus === 'timeout' || data.textStatus === 'abort' || data.textStatus === 'parsererror' ) {
|
if ( data.textStatus === 'timeout' || data.textStatus === 'abort' || data.textStatus === 'parsererror' ) {
|
||||||
code = data.textStatus;
|
code = data.textStatus;
|
||||||
} else if ( data.xhr ) {
|
} else if ( data.xhr ) {
|
||||||
code = 'http-' + ( data.xhr.status || 0 );
|
code = 'http-' + ( data.xhr.status || 0 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger( {
|
logger( {
|
||||||
action: 'saveFailure',
|
action: 'saveFailure',
|
||||||
|
|
Loading…
Reference in a new issue