| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | fetchWithTimeout, |
| 5 | 5 | retryTwice, |
| 6 | 6 | } from '@auto-launch/functions/helpers'; |
| 7 | 7 | import { AI_HOST } from '@constants'; |
| 8 | +import { digest } from '@shared/api/digest'; | |
| 8 | 9 | import { reqDataBasics } from '@shared/lib/data'; |
| 9 | 10 | |
| 10 | 11 | const fallback = { |
| 11 | 12 | launchDecisions: { navExtras: 'none', navButtonLabel: '' }, |
| @@ -18,11 +19,23 @@ | ||
| 18 | 19 | const body = JSON.stringify({ ...reqDataBasics, siteProfile }); |
| 19 | 20 | |
| 20 | 21 | const response = await retryTwice(() => |
| 21 | 22 | fetchWithTimeout(url, { method, headers, body }), |
| 22 | - ); | |
| 23 | + ).catch((error) => { | |
| 24 | + return { ok: false, statusText: error.message, status: 0 }; | |
| 25 | + }); | |
| 23 | 26 | |
| 24 | - if (!response?.ok) return fallback; | |
| 27 | + if (!response?.ok) { | |
| 28 | + digest({ | |
| 29 | + error: { | |
| 30 | + message: response.statusText, | |
| 31 | + name: 'FetchError', | |
| 32 | + status: response.status, | |
| 33 | + }, | |
| 34 | + details: { source: 'auto-launch', caller: 'handleLaunchDecisions' }, | |
| 35 | + }); | |
| 36 | + return fallback; | |
| 37 | + } | |
| 25 | 38 | |
| 26 | 39 | return failWithFallback( |
| 27 | 40 | async () => ({ |
| 28 | 41 | launchDecisions: getLaunchDecisionsShape.parse(await response.json()), |