| @@ -29,8 +29,18 @@ | ||
| 29 | 29 | return __('An unknown error occurred.', 'code-snippets') |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | + * Whether a request finished without the browser receiving a response. | |
| 34 | + * | |
| 35 | + * Nothing can be concluded about the write itself from this: the request may | |
| 36 | + * never have arrived, or it may have been handled and the response lost on the | |
| 37 | + * way back. Aborts are excluded, as the caller stopped those deliberately. | |
| 38 | + */ | |
| 39 | +export const isUnconfirmedRequest = (error: unknown): boolean => | |
| 40 | + isAxiosError(error) && !error.response && !isAbortError(error) | |
| 41 | + | |
| 42 | +/** | |
| 33 | 43 | * Explain a failed request in terms the reader can act on. |
| 34 | 44 | * |
| 35 | 45 | * An expired session is the common case worth naming: the snippet editor is a |
| 36 | 46 | * screen people leave open, and once the session lapses WordPress rejects every |
| @@ -43,9 +53,10 @@ | ||
| 43 | 53 | } |
| 44 | 54 | |
| 45 | 55 | if (!error.response) { |
| 46 | 56 | return __( |
| 47 | - 'The request did not reach your site. Check your connection, or whether a security plugin is blocking it.', | |
| 57 | + 'No response came back, so this could not be confirmed. The change may already have been saved — ' + | |
| 58 | + 'check in another tab before trying again.', | |
| 48 | 59 | 'code-snippets' |
| 49 | 60 | ) |
| 50 | 61 | } |
| 51 | 62 | |