Skip to content

Commit

Permalink
chore(lookup): Skip providers which do not support GTIN lookups
Browse files Browse the repository at this point in the history
Immediately create a warning message instead of calling the provider
only to let it throw an error (which clutters the logs).
  • Loading branch information
kellnerd committed Jun 8, 2024
1 parent 69ff14d commit 85414bd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lookup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { detectLanguageAndScript } from '@/harmonizer/language_script.ts';
import { mergeRelease } from '@/harmonizer/merge.ts';
import { defaultProviderPreferences, providers } from '@/providers/mod.ts';
import { FeatureQuality } from '@/providers/features.ts';
import { LookupError, ProviderError } from '@/utils/errors.ts';
import { ensureValidGTIN, isEqualGTIN, uniqueGtinSet } from '@/utils/gtin.ts';
import { isDefined, isNotError } from '@/utils/predicate.ts';
Expand Down Expand Up @@ -139,8 +140,16 @@ export class CombinedReleaseLookup {
for (const providerName of this.gtinLookupProviders) {
const provider = providers.findByName(providerName);
if (provider) {
this.queuedReleases.push(provider.getRelease(['gtin', this.gtin], this.options));
this.queuedProviderNames.add(provider.name);
if (provider.getQuality('GTIN lookup') != FeatureQuality.MISSING) {
this.queuedReleases.push(provider.getRelease(['gtin', this.gtin], this.options));
this.queuedProviderNames.add(provider.name);
} else {
this.messages.push({
provider: provider.name,
type: 'warning',
text: 'GTIN lookups are not supported',
});
}
} else {
this.messages.push({
type: 'error',
Expand Down

0 comments on commit 85414bd

Please sign in to comment.