files.com 1.0.191 → 1.0.192
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/_VERSION +1 -1
- package/lib/Errors.js +10 -9
- package/package.json +1 -1
- package/src/Errors.js +8 -7
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.192
|
package/lib/Errors.js
CHANGED
@@ -54,7 +54,7 @@ var FilesApiError = /*#__PURE__*/function (_FilesError) {
|
|
54
54
|
var _this2;
|
55
55
|
|
56
56
|
(0, _classCallCheck2.default)(this, FilesApiError);
|
57
|
-
_this2 = _super2.call(this, message
|
57
|
+
_this2 = _super2.call(this, message);
|
58
58
|
_this2.name = 'FilesApiError';
|
59
59
|
_this2.code = code;
|
60
60
|
return _this2;
|
@@ -75,16 +75,17 @@ var toPascalCase = function toPascalCase(string) {
|
|
75
75
|
};
|
76
76
|
|
77
77
|
var handleErrorResponse = function handleErrorResponse(error) {
|
78
|
-
var _errorData;
|
78
|
+
var _errorData, _errorData2;
|
79
79
|
|
80
80
|
var response = error.response;
|
81
81
|
var errorData = response === null || response === void 0 ? void 0 : response.data;
|
82
|
-
var
|
82
|
+
var message = ((_errorData = errorData) === null || _errorData === void 0 ? void 0 : _errorData.error) || (response === null || response === void 0 ? void 0 : response.statusText) || error.message;
|
83
|
+
var code = (response === null || response === void 0 ? void 0 : response.status) || ((_errorData2 = errorData) === null || _errorData2 === void 0 ? void 0 : _errorData2['http-code']) || 0;
|
83
84
|
|
84
85
|
if (!errorData) {
|
85
|
-
_Logger.default.error('FilesApiError Exception >', code,
|
86
|
+
_Logger.default.error('FilesApiError Exception >', code, message);
|
86
87
|
|
87
|
-
throw new FilesApiError(
|
88
|
+
throw new FilesApiError(message, code);
|
88
89
|
}
|
89
90
|
|
90
91
|
if (Array.isArray(errorData)) {
|
@@ -92,9 +93,9 @@ var handleErrorResponse = function handleErrorResponse(error) {
|
|
92
93
|
}
|
93
94
|
|
94
95
|
if (!errorData.type) {
|
95
|
-
_Logger.default.error('FilesApiError Exception >', code,
|
96
|
+
_Logger.default.error('FilesApiError Exception >', code, message);
|
96
97
|
|
97
|
-
throw new FilesApiError(
|
98
|
+
throw new FilesApiError(message, code);
|
98
99
|
}
|
99
100
|
|
100
101
|
var parts = errorData.type.split('/');
|
@@ -117,9 +118,9 @@ var handleErrorResponse = function handleErrorResponse(error) {
|
|
117
118
|
|
118
119
|
var ErrorClass = errorClasses[className];
|
119
120
|
|
120
|
-
_Logger.default.error("".concat(className, " Exception >"), code,
|
121
|
+
_Logger.default.error("".concat(className, " Exception >"), code, message);
|
121
122
|
|
122
|
-
throw new ErrorClass(
|
123
|
+
throw new ErrorClass(message, code);
|
123
124
|
}; // general errors
|
124
125
|
|
125
126
|
|
package/package.json
CHANGED
package/src/Errors.js
CHANGED
@@ -9,7 +9,7 @@ export class FilesError extends Error {
|
|
9
9
|
|
10
10
|
export class FilesApiError extends FilesError {
|
11
11
|
constructor(message, code) {
|
12
|
-
super(message
|
12
|
+
super(message)
|
13
13
|
this.name = 'FilesApiError'
|
14
14
|
this.code = code
|
15
15
|
}
|
@@ -28,11 +28,12 @@ export const handleErrorResponse = error => {
|
|
28
28
|
const response = error.response
|
29
29
|
let errorData = response?.data
|
30
30
|
|
31
|
+
const message = errorData?.error || response?.statusText || error.message
|
31
32
|
const code = response?.status || errorData?.['http-code'] || 0
|
32
33
|
|
33
34
|
if (!errorData) {
|
34
|
-
Logger.error('FilesApiError Exception >', code,
|
35
|
-
throw new FilesApiError(
|
35
|
+
Logger.error('FilesApiError Exception >', code, message)
|
36
|
+
throw new FilesApiError(message, code)
|
36
37
|
}
|
37
38
|
|
38
39
|
if (Array.isArray(errorData)) {
|
@@ -40,8 +41,8 @@ export const handleErrorResponse = error => {
|
|
40
41
|
}
|
41
42
|
|
42
43
|
if (!errorData.type) {
|
43
|
-
Logger.error('FilesApiError Exception >', code,
|
44
|
-
throw new FilesApiError(
|
44
|
+
Logger.error('FilesApiError Exception >', code, message)
|
45
|
+
throw new FilesApiError(message, code)
|
45
46
|
}
|
46
47
|
|
47
48
|
const parts = errorData.type.split('/')
|
@@ -60,8 +61,8 @@ export const handleErrorResponse = error => {
|
|
60
61
|
|
61
62
|
const ErrorClass = errorClasses[className]
|
62
63
|
|
63
|
-
Logger.error(`${className} Exception >`, code,
|
64
|
-
throw new ErrorClass(
|
64
|
+
Logger.error(`${className} Exception >`, code, message)
|
65
|
+
throw new ErrorClass(message, code)
|
65
66
|
}
|
66
67
|
|
67
68
|
// general errors
|