| @@ -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(); |