Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2957, make empty selections report an error
Browse files Browse the repository at this point in the history
Previously they were creating empty data: URLs and causing server rejection
  • Loading branch information
ianb committed Jun 2, 2017
1 parent 3c2323d commit dbeb56d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion addon/webextension/background/senderror.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ this.senderror = (function() {
MY_SHOTS: {
title: browser.i18n.getMessage("selfScreenshotErrorTitle")
},
EMPTY_SELECTION: {
title: browser.i18n.getMessage("emptySelectionErrorTitle")
},
generic: {
title: browser.i18n.getMessage("genericErrorTitle"),
info: browser.i18n.getMessage("genericErrorDetails"),
Expand Down Expand Up @@ -112,7 +115,9 @@ this.senderror = (function() {
if (!errorObj.noPopup) {
exports.showError(errorObj);
}
exports.reportError(errorObj);
if (!errorObj.noReport) {
exports.reportError(errorObj);
}
});

return exports;
Expand Down
8 changes: 8 additions & 0 deletions addon/webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
// isSaving indicates we're aleady in the middle of saving
// we use a timeout so in the case of a failure the button will
// still start working again
if (Math.floor(selectedPos.left) == Math.floor(selectedPos.right) ||
Math.floor(selectedPos.top) == Math.floor(selectedPos.bottom)) {
let exc = new Error("Empty selection");
exc.popupMessage = "EMPTY_SELECTION";
exc.noReport = true;
catcher.unhandled(exc);
return;
}
const uicontrol = global.uicontrol;
let deactivateAfterFinish = true;
if (isSaving) {
Expand Down
2 changes: 2 additions & 0 deletions docs/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ Note that any information will be serialized as JSON. Specifically `undefined`
If you add `exc.popupMessage = "Something happened"` then that detail will be added. Be careful about localization here.

Add `exc.noPopup = true` if you don't want the user notified about the error (but the error will still be sent to Sentry).

Add `exc.noReport = true` if you don't want the error reported to Sentry.
2 changes: 2 additions & 0 deletions locales/en-US/webextension.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ loginErrorDetails = We couldn’t save your shot because there is a problem with
unshootablePageErrorTitle = We can’t screenshot this page.
unshootablePageErrorDetails = This isn’t a standard Web page, so you can’t take a screenshot of it.
selfScreenshotErrorTitle = You can’t take a shot of a Firefox Screenshots page!
# Fired when someone makes a zero-width or zero-height selection
emptySelectionErrorTitle = Your selection is too small
genericErrorTitle = Whoa! Firefox Screenshots went haywire.
genericErrorDetails = We’re not sure what just happened. Care to try again or take a shot of a different page?
# Section for onboarding strings
Expand Down

0 comments on commit dbeb56d

Please # to comment.