BetterForms Error Pages API
Last updated
Last updated
This document covers the system static and app dynamic error pages and how they work. The static error page is a non-customizable page that will be shown for lower level errors (e.g. BF server, network, providers errors), and the app dynamic error page is shown for some higher-level errors (e.g. page not found, request timeout, and some FM errors like Invalid Data API token).
Errors that occur before the app is able to connect to the DB or a site record was not found, for example, will be redirected to a static page that can not be customized. The picture below is an example of the static error page.
The error page can be accessed via the nav slug /error
. It will be associated with either a default or custom page. The picture below shows the default error page.
All apps have a system-generated error page that you can override. To override, simply add a page with the reserved nav slug of /error
and you can create and customize your own page. Error detail data is saved to the app
model as app.error
, and can be accessed in the error page. The error object looks like this:
Besides customizing the error page, you can also customize how all errors are handled and override the default system behavior.
For example, the default ‘Page Not Found’ error would navigate to the /error
page but if you would rather show a toaster alert, the following could be added to the App
model.
As it can be seen above, custom behaviours are added under a reserved global actions key errorHandlers
, and that will be an array of objects. Each object having have codes
and actions
.
Key | Value |
---|---|
codes |
|
actions | array of actions |
The result from the example code above is the alert shown below.
The error data can be found under options
for each action of the array, for a given code. The error object has the same shape as previously presented here and can be accessed as follows:
Key | Path |
---|---|
| actions.options.error.code |
| actions.options.error.description |
| actions.options.error.message |