diff --git a/CHANGELOG.md b/CHANGELOG.md index 10291ca3..17c84b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Log for search-api errors. + ## [1.59.7] - 2021-12-28 ### Fixed diff --git a/node/clients/biggy-search.ts b/node/clients/biggy-search.ts index df5afd54..8bd53fa4 100644 --- a/node/clients/biggy-search.ts +++ b/node/clients/biggy-search.ts @@ -319,25 +319,33 @@ export class BiggySearchClient extends JanusClient { }) } - const result = await this.http.getRaw(url, { - params, - metric: 'search-result', - headers: { - "X-VTEX-IS-Filter": buildBSearchFilterHeader(sellers), - "X-VTEX-IS-ID": `${this.store}`, - }, - ...cache - }) - - if (!result.data?.total) { - this.context.logger.warn({ - message: 'Empty search', - url, + try { + const result = await this.http.getRaw(url, { params, + metric: 'search-result', + headers: { + "X-VTEX-IS-Filter": buildBSearchFilterHeader(sellers), + "X-VTEX-IS-ID": `${this.store}`, + }, + ...cache }) - } - return sortProducts(result.data, query) + if (!result.data?.total) { + this.context.logger.warn({ + message: 'Empty search', + url, + params, + }) + } + + return sortProducts(result.data, query) + } catch (error) { + this.context.logger.error({ + message: 'Error from search-api', + error, + }) + throw error + } } public async banners(args: BannersArgs): Promise {