From 5098685c03bb22f33f1b6e0d732e9e2fc9a6b389 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 29 Jul 2024 03:46:40 +0200 Subject: [PATCH] Improve error messages and types --- src/Logic/Tags/And.ts | 2 +- src/Logic/Tags/Or.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Logic/Tags/And.ts b/src/Logic/Tags/And.ts index a689c8b5fe..73aba302fa 100644 --- a/src/Logic/Tags/And.ts +++ b/src/Logic/Tags/And.ts @@ -191,7 +191,7 @@ export class And extends TagsFilter { const newAnds: TagsFilter[] = [] for (const tag of this.and) { if (tag instanceof And) { - throw "Optimize expressions before using removePhraseConsideredKnown" + throw "Optimize expressions before using removePhraseConsideredKnown. Found an AND in an AND: "+this.asHumanString() } if (tag instanceof Or) { const r = tag.removePhraseConsideredKnown(knownExpression, value) diff --git a/src/Logic/Tags/Or.ts b/src/Logic/Tags/Or.ts index 871361f671..fa4b01afda 100644 --- a/src/Logic/Tags/Or.ts +++ b/src/Logic/Tags/Or.ts @@ -55,7 +55,7 @@ export class Or extends TagsFilter { return choices } - asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record) { + asHumanString(linkToWiki: boolean = false, shorten: boolean = false, properties: Record = {}) { return this.or .map((t) => { let e = t.asHumanString(linkToWiki, shorten, properties) @@ -76,7 +76,7 @@ export class Or extends TagsFilter { for (const selfTag of this.or) { let matchFound = false for (let i = 0; i < other.or.length && !matchFound; i++) { - let otherTag = other.or[i] + const otherTag = other.or[i] matchFound = selfTag.shadows(otherTag) } if (!matchFound) { @@ -121,7 +121,7 @@ export class Or extends TagsFilter { const newOrs: TagsFilter[] = [] for (const tag of this.or) { if (tag instanceof Or) { - throw "Optimize expressions before using removePhraseConsideredKnown" + throw "Optimize expressions before using removePhraseConsideredKnown. Found an OR in an OR: "+this.asHumanString(false, false, {}) } if (tag instanceof And) { const r = tag.removePhraseConsideredKnown(knownExpression, value)