PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/AutoLaunch/functions/helpers.js +9 -4 3.0.4 → trunk View file →
@@ -1,6 +1,6 @@
1 1 import { useLaunchDataStore } from '@auto-launch/state/launch-data';
2 -import { __ } from '@wordpress/i18n';
2 +import { digest } from '@shared/api/digest';
3 3
4 4 export const setStatus = (msg) => {
5 5 useLaunchDataStore.getState().addStatusMessage(msg);
6 6 };
@@ -13,9 +13,9 @@
13 13 return await fn();
14 14 } catch (_) {
15 15 setErrorMessage(
16 16 // translators: This is an error message shown to the user when a network request fails and is being retried
17 - __('The network seems unstable. Retrying...', 'extendify-local'),
17 + launchStrings().errorUnstable,
18 18 );
19 19 await wait(1000);
20 20 const res = await fn();
21 21 setErrorMessage(null);
@@ -22,13 +22,17 @@
22 22 return res;
23 23 }
24 24 };
25 25
26 -export const failWithFallback = async (fn, fallback) => {
26 +export const failWithFallback = async (fn, fallback, errDetails = {}) => {
27 27 try {
28 28 return await fn();
29 29 } catch (error) {
30 - console.error('failWithFallback:', error);
30 + digest({
31 + ...errDetails,
32 + error: errDetails?.error ?? error,
33 + source: 'auto-launch',
34 + });
31 35 return fallback;
32 36 }
33 37 };
34 38
@@ -33,8 +37,9 @@
33 37 };
34 38
35 39 export const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
36 40
41 +import { launchStrings } from '@auto-launch/strings';
37 42 import apiFetch from '@wordpress/api-fetch';
38 43
39 44 export async function apiFetchWithTimeout(options = {}, timeoutMs = 30000) {
40 45 const controller = new AbortController();