Skip to content

Commit

Permalink
Added more logs to troubleshoot issues faster
Browse files Browse the repository at this point in the history
  • Loading branch information
honeyankit committed Oct 20, 2023
1 parent 50cce8c commit d77be5a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
19 changes: 19 additions & 0 deletions __tests__/api_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ describe('ApiClient', () => {
)
})

test('job details with certificate error', async () => {
const errorObject = {
isAxiosError: true,
message: 'unable to get local issuer certificate',
name: 'Error',
stack: 'Error: unable to get local issuer certificate...',
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
status: null
}

mockAxios.get.mockRejectedValue(errorObject)

await expect(api.getJobDetails()).rejects.toThrowError(
new JobDetailsFetchingError(
'fetching job details: received code null: {}. Error message: unable to get local issuer certificate'
)
)
})

test('get job credentials', async () => {
const apiResponse = {
data: {
Expand Down
18 changes: 14 additions & 4 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ export class ApiClient {
const err = error
throw new JobDetailsFetchingError(
`fetching job details: received code ${err.response
?.status}: ${JSON.stringify(err.response?.data)}`
?.status}: ${JSON.stringify(err.response?.data)}. Error message: ${
err.message
}`
)
} else {
throw error
const message = (error as {message?: string}).message
throw new JobDetailsFetchingError(
`fetching job details: Error message: ${message}`
)
}
}
}
Expand Down Expand Up @@ -91,10 +96,15 @@ export class ApiClient {
const err = error
throw new CredentialFetchingError(
`fetching credentials: received code ${err.response
?.status}: ${JSON.stringify(err.response?.data)}`
?.status}: ${JSON.stringify(err.response?.data)}. Error message: ${
err.message
}`
)
} else {
throw error
const message = (error as {message?: string}).message
throw new JobDetailsFetchingError(
`fetching credentials: Error message: ${message}`
)
}
}
}
Expand Down

0 comments on commit d77be5a

Please sign in to comment.