Skip to content

Commit c708b8d

Browse files
pkiparraMalteSehmer
andcommitted
🔊 add logmessage to throwAndDelegateError
Co-Authored-By: Malte Sehmer <[email protected]>
1 parent f8dadde commit c708b8d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/util/error.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ import { errorLogger } from "./logger.util";
99
export const throwAndDelegateError = (
1010
error: Error | AxiosError,
1111
source: string,
12-
apiKey?: string
12+
apiKey?: string,
13+
logMessage?: string
1314
) => {
14-
const message =
15+
const errorMessage =
1516
error instanceof AxiosError
1617
? error.response?.data
1718
? JSON.stringify(error.response?.data)
1819
: error.message
1920
: error.message;
20-
errorLogger(source, message, apiKey);
21+
22+
if (logMessage) {
23+
errorLogger(source, logMessage, apiKey, errorMessage);
24+
} else {
25+
errorLogger(source, errorMessage, apiKey);
26+
}
27+
2128
if (error instanceof AxiosError) {
2229
const status = error.response?.status || 500;
2330
var errorType: IntegrationErrorType;
@@ -37,7 +44,7 @@ export const throwAndDelegateError = (
3744
errorType = IntegrationErrorType.INTEGRATION_ERROR_UNAVAILABLE;
3845
break;
3946
default:
40-
throw new ServerError(status, `${source} (${message})`);
47+
throw new ServerError(status, `${source} (${errorMessage})`);
4148
}
4249
throw new ServerError(DELEGATE_TO_FRONTEND_CODE, errorType);
4350
}

0 commit comments

Comments
 (0)