| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
|
| 3 |
// Collapses any Quick Edit save/load error into a user-facing message. The raw |
| 4 |
// err.message still flows to insights via track() — only the displayed string |
| 5 |
// is generalized. An expired REST nonce gets its own copy because "try again" |
| 6 |
// is wrong advice: the page has to be refreshed to mint a fresh nonce. |
| 7 |
export const friendlyMessage = (err) => { |
| 8 |
if (err?.body?.code === 'rest_cookie_invalid_nonce') { |
| 9 |
return __( |
| 10 |
'Your session expired. Please refresh the page and try again.', |
| 11 |
'extendify-local', |
| 12 |
); |
| 13 |
} |
| 14 |
return __( |
| 15 |
'Sorry, something went wrong. Please try again or try editing something else.', |
| 16 |
'extendify-local', |
| 17 |
); |
| 18 |
}; |
| 19 |
|