From 1cfe42a81b5acc8995452b3f6a8b4a79c4bb5f43 Mon Sep 17 00:00:00 2001 From: "Lieszkovszky L. L" <16566226+lieszkol@users.noreply.github.com> Date: Sat, 16 Sep 2023 13:38:40 +0200 Subject: [PATCH] Add error handling to deal with unexpected filter types (incompatibility with FiltaQuilla or QuickFilters?) Perhaps due to incompatibility with FiltaQuilla or QuickFilters, the "Filters" add-on would completely stop working after certain special filters were defined. Adding some error handling to enable the add-on to continue functioning even in such cases. --- experiments/filters/implementation.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/experiments/filters/implementation.js b/experiments/filters/implementation.js index f07c7be..13c165d 100644 --- a/experiments/filters/implementation.js +++ b/experiments/filters/implementation.js @@ -34,7 +34,13 @@ var filters = class extends ExtensionCommon.ExtensionAPI { retval.junkPercent = val.junkPercent; break; default: - retval.str = val.str; + // For some reason "val.str" throws 0x80070057 (NS_ERROR_ILLEGAL_VALUE), ignore such cases so as not to break the Filter button completely: + try { + retval.str = val.str; + } + catch (error) { + retval.str = "Filter button error interpreting filter: " + error.str; + } break; } return retval; @@ -125,7 +131,8 @@ var filters = class extends ExtensionCommon.ExtensionAPI { async filterMatches(filterId, messageId) { let filter = filterMap[filterId]; if (!filter) { - throw new Error('Invalid or stale filterId ' + filterId); + return false; + // This should only be used when debugging the add-on: throw new Error('Invalid or stale filterId ' + filterId); } let msg = context.extension.messageManager.get(messageId);