| 1 | /** |
| 2 | * A part of a page that fails to load shows as missing, with the page |
| 3 | * still up: a loader reads what the page is about as usual (a failure |
| 4 | * there is the page's error), and each part beside it through `soft`, |
| 5 | * which gives null when it fails. The part then says it could not be |
| 6 | * loaded (components/boundary.tsx `Unavailable`) and is back on the next |
| 7 | * refresh. A 404 or a refusal is an answer, not a failure: read those as |
| 8 | * the service gives them, before `soft` hides them. |
| 9 | */ |
| 10 | export function soft<T>(work: Promise<T>, what: string): Promise<T | null> { |
| 11 | return work.catch((error) => { |
| 12 | console.warn(`g1t: ${what} could not be loaded:`, error); |
| 13 | return null; |
| 14 | }); |
| 15 | } |