Skip to content

Commit b1a767a

Browse files
committed
♻️ refactor throwAndDelegate to check for status/code instead of isAxiosError
1 parent ce63fc3 commit b1a767a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/error.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { errorLogger } from "./logger.util";
88

99
export const throwAndDelegateError = (
10-
error: AxiosError | Error,
10+
error: AxiosError | ServerError | Error,
1111
source: string,
1212
apiKey: string | undefined,
1313
logMessage?: string
@@ -23,9 +23,12 @@ export const throwAndDelegateError = (
2323
} else {
2424
errorLogger(source, errorMessage, apiKey);
2525
}
26-
if (axios.isAxiosError(error)) {
26+
27+
const err = error as any;
28+
if (err.code || err.response?.status) {
2729
const status =
28-
error.response?.status || (error.code ? parseInt(error.code) : 500);
30+
err.response?.status || (err.code ? parseInt(err.code) : 500);
31+
2932
var errorType: IntegrationErrorType;
3033
switch (status) {
3134
case 401:

0 commit comments

Comments
 (0)