Improve error messages and types

This commit is contained in:
Pieter Vander Vennet 2024-07-29 03:46:40 +02:00
parent 1f9b849bd3
commit 5098685c03
2 changed files with 4 additions and 4 deletions

View file

@ -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)

View file

@ -55,7 +55,7 @@ export class Or extends TagsFilter {
return choices
}
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) {
asHumanString(linkToWiki: boolean = false, shorten: boolean = false, properties: Record<string, string> = {}) {
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)