Error Handling
Errors can happen, and so by including an error handler in your response processing we can ensure that users are always informed.
If an input is invalid, or another error is caught, the responseBuilder
can return a functionFailure
,
The failureParams object is a particular type used to indicate how to handle the error. It contains an error BlockPointer, pointing to a block with an error message, as well as two optional fields, resetForm
and tryAgain
, defaulting to true.
resetForm
indicates that the form should be unset, similarly to the unsetFunctionForm
function
tryAgain
offers a button to try again if true
For example, in the division handler, one such case of invalid input, is a divide by zero error. This is a number that cannot be divided by as of yet, so that number is checked early in the function, before further logic.
Last updated