From a01645daf07d583c5186718a9f55663f70c5157d Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sat, 2 Nov 2019 10:28:25 -0500 Subject: [PATCH] Fix error message when saving an empty usercss. Closes #795 --- _locales/en/messages.json | 4 ++++ js/usercss.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index c8368fad..62b078c4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1161,6 +1161,10 @@ "message": "Restore removed section", "description": "Label for the button to restore a removed section" }, + "sectionEmpty": { + "message": "Not saved due to lack of usercss sections.\n\nAdd at least one @-moz-document domain(\"example.com\") {} section", + "description": "Error shown when the user tries to save an empty usercss style" + }, "shortcuts": { "message": "Shortcuts", "description": "Go to shortcut configuration" diff --git a/js/usercss.js b/js/usercss.js index 85937ec6..a0c68ca6 100644 --- a/js/usercss.js +++ b/js/usercss.js @@ -71,6 +71,9 @@ const usercss = (() => { .then(({sections, errors}) => { if (!errors.length) errors = false; if (!sections.length || errors && !allowErrors) { + if (!errors) { + errors = chrome.i18n.getMessage('sectionEmpty'); + } throw errors; } style.sections = sections;