Skip to content

Commit

Permalink
Merge branch 'release-1.23.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol-Stelmaczonek committed Mar 16, 2023
2 parents 32537a8 + 67100a4 commit 052cac3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-core-sdk",
"version": "1.22.0",
"version": "1.23.0",
"displayName": "TAO Core SDK",
"description": "Core libraries of TAO",
"homepage": "https://github.com/oat-sa/tao-core-sdk-fe#readme",
Expand Down
16 changes: 11 additions & 5 deletions src/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ const logger = loggerFactory('core/request');
*/
const createError = (response, fallbackMessage, httpCode, httpSent) => {
let err;
if (response && response.errorCode) {
err = new Error(`${response.errorCode} : ${response.errorMsg || response.errorMessage || response.error}`);
} else {
err = new Error(fallbackMessage);
if (response) {
const code = response.errorCode || response.code;
const message = response.errorMsg || response.errorMessage || response.error || response.message;
if (code && message) {
err = new Error(`${code} : ${message}`);
} else if (message) {
err = new Error(`${message}`);
} else {
err = new Error(fallbackMessage);
}
}
err.response = response;
err.sent = httpSent;
Expand Down Expand Up @@ -301,7 +307,7 @@ export default function request(options) {
sent: xhr.readyState > 0,
type: 'error',
textStatus: textStatus,
message: errorThrown || __('An error occurred!')
message: errorThrown || xhr.statusText || __('An error occurred!')
};

const enhancedResponse = Object.assign({}, responseExtras, response);
Expand Down
4 changes: 2 additions & 2 deletions test/core/request/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ define(['jquery', 'lodash', 'core/request', 'core/tokenHandler', 'core/jwt/jwtTo
title: 'disconnected',
url: '//offline',
reject: true,
err: new Error('0 : timeout'),
err: new Error('timeout'),
reuseToken: true
}
])
Expand Down Expand Up @@ -522,7 +522,7 @@ define(['jquery', 'lodash', 'core/request', 'core/tokenHandler', 'core/jwt/jwtTo
code: 0,
sent: false,
source: 'network',
message: '0 : timeout'
message: 'timeout'
},
'//202': {
code: 202,
Expand Down

0 comments on commit 052cac3

Please sign in to comment.