PluginProbe
Code Snippets / 4.0.0-beta.3
Code Snippets v4.0.0-beta.3
4.0.0-beta.3 4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 All 66 releases
← All changes | js/utils/errors.ts +12 -1 4.0.0-beta.2 → 4.0.0-beta.3 View file →
@@ -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