mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +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 );
|
||||
}
|
||||
|
||||
if ( code instanceof Error ) {
|
||||
code = 'exception';
|
||||
}
|
||||
// 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' ) {
|
||||
code = data.textStatus;
|
||||
} else if ( data.xhr ) {
|
||||
code = 'http-' + ( data.xhr.status || 0 );
|
||||
if ( data ) {
|
||||
if ( data.textStatus === 'timeout' || data.textStatus === 'abort' || data.textStatus === 'parsererror' ) {
|
||||
code = data.textStatus;
|
||||
} else if ( data.xhr ) {
|
||||
code = 'http-' + ( data.xhr.status || 0 );
|
||||
}
|
||||
}
|
||||
|
||||
logger( {
|
||||
|
|
Loading…
Reference in a new issue