Skip to content

Commit

Permalink
Merge pull request #47 from ApplauseOSS/fix-auto-api-error-logging
Browse files Browse the repository at this point in the history
Fix Auto-API Error Logging
  • Loading branch information
rconner46 authored Aug 2, 2024
2 parents e341e41 + 0ab3acc commit 007baba
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 21 deletions.
8 changes: 3 additions & 5 deletions dist/index.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions dist/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions src/auto-api/auto-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosInstance, AxiosResponse } from 'axios';
import axios, { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
import {
CreateTestCaseResultDto,
CreateTestCaseResultResponseDto,
Expand Down Expand Up @@ -39,15 +39,13 @@ export class AutoApi {
function (response: AxiosResponse<any, any>) {
return response;
},
function (error) {
function (error: AxiosError) {
// log and rethrow
const errText =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
error.data !== undefined
? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
error.data
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
`error-code [${error.response.status}] with error [${error.response.statusText}]`;
error.response?.data !== undefined
? JSON.stringify(error.response.data)
: `error-code [${error.response?.status}] with error [${error.response?.statusText}]`;
console.error(`Auto-Api returned ${errText}`);
return Promise.reject(error);
}
Expand Down

0 comments on commit 007baba

Please sign in to comment.