jordy 0.20.7 → 0.20.9
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/esm5/http-api/BaseInterceptorHttpApi.js +6 -6
- package/esm5/http-api/BasicHttpApi.js +8 -10
- package/esm5/http-api/BasicHttpUploadApi.js +2 -2
- package/esm5/http-api/HttpRestError.js +21 -0
- package/esm5/http-api/axios/throwableAxiosErrorParser.js +1 -19
- package/libs/http-api/BaseInterceptorHttpApi.d.ts +1 -1
- package/libs/http-api/HttpRestError.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
+
import { HttpRestError } from './HttpRestError';
|
|
2
3
|
var BaseInterceptorHttpApi = (function () {
|
|
3
4
|
function BaseInterceptorHttpApi(paramsSerializer) {
|
|
4
5
|
var _this = this;
|
|
@@ -26,20 +27,19 @@ var BaseInterceptorHttpApi = (function () {
|
|
|
26
27
|
if (serializedParams[0] === '?') {
|
|
27
28
|
return url + serializedParams;
|
|
28
29
|
}
|
|
29
|
-
return (url +
|
|
30
|
-
(url.includes('?') ? '&' : '?') +
|
|
31
|
-
serializedParams);
|
|
30
|
+
return url + (url.includes('?') ? '&' : '?') + serializedParams;
|
|
32
31
|
}
|
|
33
32
|
return url;
|
|
34
33
|
};
|
|
35
|
-
this.throwWithInterceptor = function (err) {
|
|
34
|
+
this.throwWithInterceptor = function (err, method, url) {
|
|
35
|
+
var refinedError = HttpRestError.withUrl(err, method, url);
|
|
36
36
|
if (_this._interceptor.error) {
|
|
37
|
-
var nextError = _this._interceptor.error(
|
|
37
|
+
var nextError = _this._interceptor.error(refinedError);
|
|
38
38
|
if (nextError) {
|
|
39
39
|
throw nextError;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
throw
|
|
42
|
+
throw refinedError;
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
Object.defineProperty(BaseInterceptorHttpApi.prototype, "interceptor", {
|
|
@@ -33,7 +33,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
33
33
|
case 2: return [2, _a.sent()];
|
|
34
34
|
case 3:
|
|
35
35
|
error_1 = _a.sent();
|
|
36
|
-
this.throwWithInterceptor(error_1);
|
|
36
|
+
this.throwWithInterceptor(error_1, 'get', url);
|
|
37
37
|
return [3, 4];
|
|
38
38
|
case 4: return [2];
|
|
39
39
|
}
|
|
@@ -61,7 +61,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
61
61
|
case 2: return [2, _a.sent()];
|
|
62
62
|
case 3:
|
|
63
63
|
error_2 = _a.sent();
|
|
64
|
-
this.throwWithInterceptor(error_2);
|
|
64
|
+
this.throwWithInterceptor(error_2, 'post', url);
|
|
65
65
|
return [3, 4];
|
|
66
66
|
case 4: return [2];
|
|
67
67
|
}
|
|
@@ -89,7 +89,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
89
89
|
case 2: return [2, _a.sent()];
|
|
90
90
|
case 3:
|
|
91
91
|
error_3 = _a.sent();
|
|
92
|
-
this.throwWithInterceptor(error_3);
|
|
92
|
+
this.throwWithInterceptor(error_3, 'put', url);
|
|
93
93
|
return [3, 4];
|
|
94
94
|
case 4: return [2];
|
|
95
95
|
}
|
|
@@ -117,7 +117,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
117
117
|
case 2: return [2, _a.sent()];
|
|
118
118
|
case 3:
|
|
119
119
|
error_4 = _a.sent();
|
|
120
|
-
this.throwWithInterceptor(error_4);
|
|
120
|
+
this.throwWithInterceptor(error_4, 'patch', url);
|
|
121
121
|
return [3, 4];
|
|
122
122
|
case 4: return [2];
|
|
123
123
|
}
|
|
@@ -145,7 +145,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
145
145
|
case 2: return [2, _a.sent()];
|
|
146
146
|
case 3:
|
|
147
147
|
error_5 = _a.sent();
|
|
148
|
-
this.throwWithInterceptor(error_5);
|
|
148
|
+
this.throwWithInterceptor(error_5, 'delete', url);
|
|
149
149
|
return [3, 4];
|
|
150
150
|
case 4: return [2];
|
|
151
151
|
}
|
|
@@ -153,11 +153,9 @@ var BasicHttpApi = (function (_super) {
|
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
155
|
BasicHttpApi.prototype.getFile = function (url, params, filename) {
|
|
156
|
-
return this.getBlob(url, params)
|
|
157
|
-
.then(function (blob) {
|
|
156
|
+
return this.getBlob(url, params).then(function (blob) {
|
|
158
157
|
return new File([blob], filename || getFileName(url));
|
|
159
|
-
})
|
|
160
|
-
.catch(this.throwWithInterceptor);
|
|
158
|
+
});
|
|
161
159
|
};
|
|
162
160
|
BasicHttpApi.prototype.getBlob = function (url, params) {
|
|
163
161
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -179,7 +177,7 @@ var BasicHttpApi = (function (_super) {
|
|
|
179
177
|
case 2: return [2, _a.sent()];
|
|
180
178
|
case 3:
|
|
181
179
|
error_6 = _a.sent();
|
|
182
|
-
this.throwWithInterceptor(error_6);
|
|
180
|
+
this.throwWithInterceptor(error_6, 'get', url);
|
|
183
181
|
return [3, 4];
|
|
184
182
|
case 4: return [2];
|
|
185
183
|
}
|
|
@@ -32,7 +32,7 @@ var BasicHttpUploadApi = (function (_super) {
|
|
|
32
32
|
case 2: return [2, _a.sent()];
|
|
33
33
|
case 3:
|
|
34
34
|
error_1 = _a.sent();
|
|
35
|
-
this.throwWithInterceptor(error_1);
|
|
35
|
+
this.throwWithInterceptor(error_1, 'post', url);
|
|
36
36
|
return [3, 4];
|
|
37
37
|
case 4: return [2];
|
|
38
38
|
}
|
|
@@ -60,7 +60,7 @@ var BasicHttpUploadApi = (function (_super) {
|
|
|
60
60
|
case 2: return [2, _a.sent()];
|
|
61
61
|
case 3:
|
|
62
62
|
error_2 = _a.sent();
|
|
63
|
-
this.throwWithInterceptor(error_2);
|
|
63
|
+
this.throwWithInterceptor(error_2, 'put', url);
|
|
64
64
|
return [3, 4];
|
|
65
65
|
case 4: return [2];
|
|
66
66
|
}
|
|
@@ -121,6 +121,27 @@ var HttpRestError = (function () {
|
|
|
121
121
|
}
|
|
122
122
|
return new HttpRestError();
|
|
123
123
|
};
|
|
124
|
+
HttpRestError.withUrl = function (error, method, url) {
|
|
125
|
+
if (HttpRestError.isHttpRestErrorLike(error)) {
|
|
126
|
+
return new HttpRestError(error.message, {
|
|
127
|
+
method: error.method || method,
|
|
128
|
+
url: error.url || url,
|
|
129
|
+
status: HttpRestError.toStatusCodeFrom(error.errorType),
|
|
130
|
+
errorType: error.errorType,
|
|
131
|
+
rawData: error.rawData,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
var meta = {
|
|
135
|
+
method: method,
|
|
136
|
+
url: url,
|
|
137
|
+
status: 0,
|
|
138
|
+
rawData: error,
|
|
139
|
+
};
|
|
140
|
+
if (HttpRestError.isErrorLike(error)) {
|
|
141
|
+
return new HttpRestError(error.message, meta);
|
|
142
|
+
}
|
|
143
|
+
return new HttpRestError(HttpRestError.DEFAULT_MESSAGE, meta);
|
|
144
|
+
};
|
|
124
145
|
HttpRestError.DEFAULT_MESSAGE = '알 수 없는 서버 오류입니다.';
|
|
125
146
|
return HttpRestError;
|
|
126
147
|
}());
|
|
@@ -30,24 +30,6 @@ export function throwableAxiosErrorParser(error, method, url) {
|
|
|
30
30
|
throw new HttpRestError(HttpRestError.DEFAULT_MESSAGE, meta);
|
|
31
31
|
}
|
|
32
32
|
if (method && url) {
|
|
33
|
-
|
|
34
|
-
throw new HttpRestError(error.message, {
|
|
35
|
-
method: error.method || method,
|
|
36
|
-
url: error.url || url,
|
|
37
|
-
status: HttpRestError.toStatusCodeFrom(error.errorType),
|
|
38
|
-
errorType: error.errorType,
|
|
39
|
-
rawData: error.rawData,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
var meta = {
|
|
43
|
-
method: method,
|
|
44
|
-
url: url,
|
|
45
|
-
status: 0,
|
|
46
|
-
rawData: error,
|
|
47
|
-
};
|
|
48
|
-
if (HttpRestError.isErrorLike(error)) {
|
|
49
|
-
throw new HttpRestError(error.message, meta);
|
|
50
|
-
}
|
|
51
|
-
throw new HttpRestError(HttpRestError.DEFAULT_MESSAGE, meta);
|
|
33
|
+
throw HttpRestError.withUrl(error, method, url);
|
|
52
34
|
}
|
|
53
35
|
}
|
|
@@ -8,5 +8,5 @@ export declare class BaseInterceptorHttpApi {
|
|
|
8
8
|
constructor(paramsSerializer: (params: any) => string);
|
|
9
9
|
mergeParams: <P>(method: RestHttpMethodType, url: string, paramsOriginal?: P) => Record<string, any>;
|
|
10
10
|
mergeQueries: <P>(method: RestHttpMethodType, url: string, paramsOriginal?: P) => string;
|
|
11
|
-
throwWithInterceptor: <E extends HttpRestErrorLike = any>(err: E) => Promise<any>;
|
|
11
|
+
throwWithInterceptor: <E extends HttpRestErrorLike = any>(err: E, method: RestHttpMethodType, url: string) => Promise<any>;
|
|
12
12
|
}
|
|
@@ -43,4 +43,5 @@ export declare class HttpRestError implements Error, HttpRestErrorLike {
|
|
|
43
43
|
static isHttpRestErrorLike(error: unknown): error is HttpRestErrorLike;
|
|
44
44
|
static from(error: ErrorLike | string | HttpRestErrorLike): HttpRestError;
|
|
45
45
|
static from(error: ErrorLike | string, errorType?: HttpRestErrorType): HttpRestError;
|
|
46
|
+
static withUrl(error: ErrorLike, method: RestHttpMethodType, url: string): HttpRestError;
|
|
46
47
|
}
|