Skip to content

Commit

Permalink
morebits: fix handling of hard errors (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Oct 26, 2022
1 parent 7ba60f2 commit ecb0f9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,9 @@ Morebits.wiki.page = function(pageName, status) {

// hard error, give up
} else {
var response = ctx.saveApi.getResponse();
var errorData = response.error || // bc error format
response.errors[0].data; // html/wikitext/plaintext error format

switch (errorCode) {

Expand All @@ -4073,18 +4076,18 @@ Morebits.wiki.page = function(pageName, status) {
break;

case 'abusefilter-disallowed':
ctx.statusElement.error('The edit was disallowed by the edit filter: "' + ctx.saveApi.getResponse().error.abusefilter.description + '".');
ctx.statusElement.error('The edit was disallowed by the edit filter: "' + errorData.abusefilter.description + '".');
break;

case 'abusefilter-warning':
ctx.statusElement.error([ 'A warning was returned by the edit filter: "', ctx.saveApi.getResponse().error.abusefilter.description, '". If you wish to proceed with the edit, please carry it out again. This warning will not appear a second time.' ]);
ctx.statusElement.error([ 'A warning was returned by the edit filter: "', errorData.abusefilter.description, '". If you wish to proceed with the edit, please carry it out again. This warning will not appear a second time.' ]);
// We should provide the user with a way to automatically retry the action if they so choose -
// I can't see how to do this without creating a UI dependency on Morebits.wiki.page though -- TTO
break;

case 'spamblacklist':
// If multiple items are blacklisted, we only return the first
var spam = ctx.saveApi.getResponse().error.spamblacklist.matches[0];
var spam = errorData.spamblacklist.matches[0];
ctx.statusElement.error('Could not save the page because the URL ' + spam + ' is on the spam blacklist');
break;

Expand Down

0 comments on commit ecb0f9c

Please sign in to comment.