This article discusses how to supply a custom error message for errors:
- Load failed
- Failed to fetch
- Okta Widget
- embedded
- custom domain
- Widget Configuration
When network errors occur during login, the Okta Widget will display the error message returned from the Fetch client.
Often, a catch-all generic error message of either "Load failed" or "Failed to fetch" will be returned.
These types of network errors are outside the widget’s control, and the exact message returned from the Fetch client will be displayed.
There are no i18n property keys for these errors.
Both Load failed and Failed to fetch can be customized using the afterError handler available in the widget.
NOTE: If multiple languages are supported, the below code will need to check the browser's language and set 'error.xhr.responseJSON.errorSummary' accordingly.
widget.on('afterError', (_context, error) => {
if (error.errorSummary === 'Failed to fetch' || error.errorSummary === 'Load failed') {
error.xhr.responseJSON.errorSummary = 'Please Check your Network Connection and try again';
}
});
