Skip to content

Commit

Permalink
UnblockReview: mw.notify on error
Browse files Browse the repository at this point in the history
related #240 silently fails when reason begins with a line break
  • Loading branch information
NovemLinguae committed Nov 12, 2024
1 parent fe190bb commit 74d9867
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion UnblockReview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ TODO:
// look at the innerHtml of the button to see if it says "Accept" or "Decline"
const acceptOrDecline = $( this ).text().toLowerCase();
const appealReason = hrEl.nextElementSibling.nextElementSibling.childNodes[ 0 ].textContent;
// FIXME: should handle this case (|reason=\nText, https://github.com/NovemLinguae/UserScripts/issues/240) instead of throwing an error
if ( appealReason === '\n' ) {
mw.notify( 'UnblockReview error 1: unable to find decline reason by scanning HTML', { type: 'error' } );
return;
}
$.getJSON(
mw.util.wikiScript( 'api' ),
{
Expand All @@ -94,7 +99,8 @@ TODO:
const acceptDeclineReason = reasonArea.value;
const wikitext2 = unblockReview.processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline );
if ( wikitext === wikitext2 ) {
mw.notify( 'UnblockReview error: unable to determine write location.' );
mw.notify( 'UnblockReview error 2: unable to determine write location.', { type: 'error' } );
return;
}

// build edit summary
Expand Down

0 comments on commit 74d9867

Please sign in to comment.