@stackfactor/client-api 1.0.60 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/axiosClient.js +4 -4
- package/package.json +1 -1
package/lib/axiosClient.js
CHANGED
|
@@ -15,7 +15,7 @@ const client = axios.create({
|
|
|
15
15
|
* Returns the error as a string
|
|
16
16
|
* @param {Object} error
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
const errorToString = (error) => {
|
|
19
19
|
if (error != null) {
|
|
20
20
|
if (error?.response?.data) {
|
|
21
21
|
let asString = "";
|
|
@@ -44,7 +44,7 @@ export const errorToString = (error) => {
|
|
|
44
44
|
* @param {Object} error
|
|
45
45
|
* @returns {Number} The error code
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
const getErrorType = (error) => {
|
|
48
48
|
if (error?.response?.status) {
|
|
49
49
|
return error.response.status;
|
|
50
50
|
} else return responseType.SERVICE_UNAVAILABLE;
|
|
@@ -55,7 +55,7 @@ export const getErrorType = (error) => {
|
|
|
55
55
|
* @param {Object} error
|
|
56
56
|
* @returns Object
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
const getErrorInformation = (error) => {
|
|
59
59
|
return {
|
|
60
60
|
status: getErrorType(error),
|
|
61
61
|
message: errorToString(error),
|
|
@@ -67,7 +67,7 @@ export const getErrorInformation = (error) => {
|
|
|
67
67
|
* @param {Boolean} returnAllExceptions - If set true all exceptions will be passed
|
|
68
68
|
* @param {Object} error - The error returned by the server
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
const shouldReturnError = (returnAllExceptions, error) => {
|
|
71
71
|
if (getErrorType(error) === responseType.UNAUTHORIZED) {
|
|
72
72
|
return returnAllExceptions;
|
|
73
73
|
} else {
|