Skip to content

Commit

Permalink
Merge pull request #187 from vtex-apps/fix/log-error
Browse files Browse the repository at this point in the history
Add error log
  • Loading branch information
thalytafabrine authored Jan 4, 2022
2 parents 6099adc + e34b013 commit 0342fda
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 24 additions & 16 deletions node/clients/biggy-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
Expand Down

0 comments on commit 0342fda

Please sign in to comment.