Skip to content

Commit 6912ed5

Browse files
feat: update axios log messages (#487)
It is difficult to group the current axios error messages, because they contain a bunch of data that can vary based on i18n or course ids in urls, etc. Since this data is provided in the custom attributes separately, it is being removed from the actual messages. Co-authored-by: Abdullah Waheed <abdullah.waheed@arbisoft.com>
1 parent 5e7640e commit 6912ed5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/auth/AxiosJwtAuthService.test.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ describe('authenticatedHttpClient usage', () => {
471471
expectNoCallToCsrfTokenFetch();
472472
expectLogFunctionToHaveBeenCalledWithMessage(
473473
mockLoggingService.logError.mock.calls[0],
474-
'[frontend-auth] Axios Error (Response): 403 http://localhost:18000/login_refresh (empty response)',
474+
'[frontend-auth] Axios Error (Response): 403 - See custom attributes for details.',
475475
{
476476
httpErrorRequestMethod: 'post',
477477
httpErrorResponseData: '(empty response)',
@@ -500,7 +500,7 @@ describe('authenticatedHttpClient usage', () => {
500500
expectNoCallToCsrfTokenFetch();
501501
expectLogFunctionToHaveBeenCalledWithMessage(
502502
mockLoggingService.logError.mock.calls[0],
503-
'[frontend-auth] Axios Error (Config): timeout of 0ms exceeded post http://localhost:18000/login_refresh',
503+
'[frontend-auth] Axios Error (Config): See custom attributes for details.',
504504
{
505505
httpErrorRequestMethod: 'post',
506506
httpErrorMessage: 'timeout of 0ms exceeded',
@@ -700,7 +700,7 @@ describe('authenticatedHttpClient usage', () => {
700700
return client.get('/unauthorized').catch(() => {
701701
expectLogFunctionToHaveBeenCalledWithMessage(
702702
mockLoggingService.logInfo.mock.calls[0],
703-
'Axios Error (Response): 401 /unauthorized (empty response)',
703+
'Axios Error (Response): 401 - See custom attributes for details.',
704704
{
705705
httpErrorRequestMethod: 'get',
706706
httpErrorStatus: 401,
@@ -719,7 +719,7 @@ describe('authenticatedHttpClient usage', () => {
719719
return client.get('/forbidden').catch(() => {
720720
expectLogFunctionToHaveBeenCalledWithMessage(
721721
mockLoggingService.logInfo.mock.calls[0],
722-
'Axios Error (Response): 403 /forbidden (empty response)',
722+
'Axios Error (Response): 403 - See custom attributes for details.',
723723
{
724724
httpErrorRequestMethod: 'get',
725725
httpErrorStatus: 403,
@@ -1068,7 +1068,7 @@ describe('Cache Functionality', () => {
10681068
expectNoCallToCsrfTokenFetch();
10691069
expectLogFunctionToHaveBeenCalledWithMessage(
10701070
mockLoggingService.logError.mock.calls[0],
1071-
'[frontend-auth] Axios Error (Response): 403 http://localhost:18000/login_refresh (empty response)',
1071+
'[frontend-auth] Axios Error (Response): 403 - See custom attributes for details.',
10721072
{
10731073
httpErrorRequestMethod: 'post',
10741074
httpErrorResponseData: '(empty response)',

src/auth/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const processAxiosError = (axiosErrorObject) => {
6767
httpErrorRequestUrl,
6868
httpErrorRequestMethod,
6969
};
70-
error.message = `Axios Error (Response): ${status} ${httpErrorRequestUrl} ${httpErrorResponseData}`;
70+
error.message = `Axios Error (Response): ${status} - See custom attributes for details.`;
7171
} else if (request) {
7272
error.customAttributes = {
7373
...error.customAttributes,
@@ -78,7 +78,7 @@ const processAxiosError = (axiosErrorObject) => {
7878
};
7979
// This case occurs most likely because of intermittent internet connection issues
8080
// but it also, though less often, catches CORS or server configuration problems.
81-
error.message = `Axios Error (Request): ${error.message} (possible local connectivity issue) ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;
81+
error.message = 'Axios Error (Request): (Possible local connectivity issue.) See custom attributes for details.';
8282
} else {
8383
error.customAttributes = {
8484
...error.customAttributes,
@@ -87,7 +87,7 @@ const processAxiosError = (axiosErrorObject) => {
8787
httpErrorRequestUrl,
8888
httpErrorRequestMethod,
8989
};
90-
error.message = `Axios Error (Config): ${error.message} ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;
90+
error.message = 'Axios Error (Config): See custom attributes for details.';
9191
}
9292

9393
return error;

0 commit comments

Comments
 (0)