@xh/hoist 70.0.0-SNAPSHOT.1729556157108 → 70.0.0-SNAPSHOT.1730999731048
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
CHANGED
|
@@ -18,9 +18,7 @@ export declare class Exception {
|
|
|
18
18
|
* Other inputs will be treated as the `message` of a new HoistException.
|
|
19
19
|
*/
|
|
20
20
|
static create(src: unknown): HoistException;
|
|
21
|
-
/**
|
|
22
|
-
* Create an Error for when an operation (e.g. a Promise) times out.
|
|
23
|
-
*/
|
|
21
|
+
/** Create an Error for when an operation (e.g. a Promise) times out. */
|
|
24
22
|
static timeout(config: TimeoutExceptionConfig): TimeoutException;
|
|
25
23
|
/**
|
|
26
24
|
* Create an Error to throw when a fetch call returns a !ok response.
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2024 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
+
import {PlainObject, XH} from '@xh/hoist/core';
|
|
7
8
|
import {FetchOptions} from '@xh/hoist/svc';
|
|
8
|
-
import {
|
|
9
|
+
import {pluralize} from '@xh/hoist/utils/js';
|
|
9
10
|
import {isPlainObject} from 'lodash';
|
|
10
|
-
|
|
11
11
|
import {FetchException, HoistException, TimeoutException, TimeoutExceptionConfig} from './Types';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -39,15 +39,19 @@ export class Exception {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Create an Error for when an operation (e.g. a Promise) times out.
|
|
44
|
-
*/
|
|
42
|
+
/** Create an Error for when an operation (e.g. a Promise) times out. */
|
|
45
43
|
static timeout(config: TimeoutExceptionConfig): TimeoutException {
|
|
46
44
|
const {interval, ...rest} = config,
|
|
47
|
-
|
|
45
|
+
// Display timeout in seconds if an even multiple (or very close to it).
|
|
46
|
+
displayInterval =
|
|
47
|
+
interval % 1000 < 5
|
|
48
|
+
? pluralize('second', Math.round(interval / 1000), true)
|
|
49
|
+
: `${interval}ms`;
|
|
50
|
+
|
|
48
51
|
return this.createInternal({
|
|
49
52
|
name: 'Timeout Exception',
|
|
50
|
-
message
|
|
53
|
+
// Note FetchService.managedFetchAsync appends to this message - review if changing.
|
|
54
|
+
message: `Timed out after ${displayInterval}`,
|
|
51
55
|
isTimeout: true,
|
|
52
56
|
stack: null,
|
|
53
57
|
interval,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "70.0.0-SNAPSHOT.
|
|
3
|
+
"version": "70.0.0-SNAPSHOT.1730999731048",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|
package/svc/FetchService.ts
CHANGED
|
@@ -314,7 +314,8 @@ export class FetchService extends HoistService {
|
|
|
314
314
|
const msg =
|
|
315
315
|
isObject(timeout) && 'message' in timeout
|
|
316
316
|
? timeout.message
|
|
317
|
-
:
|
|
317
|
+
: // Exception.timeout() message already includes interval - add URL here.
|
|
318
|
+
e.message + ` loading '${opts.url}'`;
|
|
318
319
|
throw Exception.fetchTimeout(opts, e, msg);
|
|
319
320
|
}
|
|
320
321
|
|