Skip to content

Commit

Permalink
chore(documents-v2): Catch error and log warning (#16207)
Browse files Browse the repository at this point in the history
* Catch error and log warning

* Update libs/api/domains/documents/src/lib/documentV2.service.ts

Co-authored-by: Þorkell Máni Þorkelsson <wowthorkell@gmail.com>

---------

Co-authored-by: Þorkell Máni Þorkelsson <wowthorkell@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and thoreyjona committed Oct 2, 2024
1 parent 46dca08 commit b33f056
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions libs/api/domains/documents/src/lib/documentV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,26 @@ export class DocumentServiceV2 {
documentId: string,
pageSize: number,
): Promise<DocumentPageNumber> {
const res = await this.documentService.getPageNumber(
nationalId,
documentId,
pageSize,
)
const defaultRes = 1
try {
const res = await this.documentService.getPageNumber(
nationalId,
documentId,
pageSize,
)

return {
pageNumber: res ?? 1,
return {
pageNumber: res ?? defaultRes,
}
} catch (exception) {
this.logger.warn('Document page number error', {
category: LOG_CATEGORY,
documentId,
error: exception,
})
return {
pageNumber: defaultRes,
}
}
}

Expand Down

0 comments on commit b33f056

Please sign in to comment.