@soleil-se/app-util 5.6.4 → 5.6.5
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/CHANGELOG.md +4 -0
- package/client/fetch-json/index.js +6 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
|
|
|
7
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
8
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
9
9
|
|
|
10
|
+
## [5.6.5] - 2024-01-25
|
|
11
|
+
|
|
12
|
+
- Fix asynchronous handling of error in `fetchJson`.
|
|
13
|
+
|
|
10
14
|
## [5.6.4] - 2024-01-18
|
|
11
15
|
|
|
12
16
|
- Cast `Packages.java.util.UUID.randomUUID()` to `string`.
|
|
@@ -16,19 +16,20 @@ async function toJson(response) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
async function
|
|
19
|
+
async function responseError(response) {
|
|
20
20
|
const json = await toJson(response) || {};
|
|
21
21
|
const error = new Error(json?.message || response?.statusText);
|
|
22
22
|
Object.entries(json).forEach(([key, value]) => {
|
|
23
23
|
error[key] = value;
|
|
24
24
|
});
|
|
25
25
|
error.status = response.status;
|
|
26
|
-
|
|
26
|
+
return error;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async function handleResponse(response) {
|
|
30
|
-
if (!response.ok)
|
|
31
|
-
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw await responseError(response);
|
|
32
|
+
}
|
|
32
33
|
const json = await toJson(response);
|
|
33
34
|
if (!json) {
|
|
34
35
|
throw new Error('Response could not be parsed as JSON.');
|
|
@@ -40,7 +41,7 @@ export default function fetchJson(uri, { params = {}, retries = 0, ...options }
|
|
|
40
41
|
return fetch(getUrl(uri, params), options)
|
|
41
42
|
.then(handleResponse)
|
|
42
43
|
.catch((error) => {
|
|
43
|
-
const isTimeout = error.status === 504 || error.status === 408 || error.message
|
|
44
|
+
const isTimeout = error.status === 504 || error.status === 408 || error.message?.includes('SocketTimeoutException');
|
|
44
45
|
if (isTimeout && retries > 0) {
|
|
45
46
|
return fetchJson(uri, { ...options, params, retries: retries - 1 });
|
|
46
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/app-util",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.5",
|
|
4
4
|
"description": "Utility and rendering functions for WebApps.",
|
|
5
5
|
"main": "./common/index.js",
|
|
6
6
|
"author": "Soleil AB",
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@sitevision/api": "*"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "856a9af56cc90fa6bd3e02a1a167a486e89c84e3",
|
|
18
18
|
"dependencies": {}
|
|
19
19
|
}
|