How to handle unknown errors from a model
Introduction
When a model is computed as part of your solution it might fail for unknown reasons. Such reasons might include:
- A problem with the user’s access rights
- A hickup in the user’s internet connection
- An execution timeout or unhandled execution error
Regardless of the cause, it is a good idea to help the user understand what is going on. This guide focusses on setting up a so called snackbar notification message for such events. It is advised to always include this for your models.
A word on the model error status
This guide refers to the model error
status. This status should not be confused with the model having errors (think orange or red boxes in the Grasshopper UI). In general, when a model contains errors it still computes with a success
status. In this case some of the outputs of which their upstream components had errors might be empty. It is advised to think about these scenarios and handle them in your solution accordingly (e.g. output warning and error messages).
When a model computes with the error
status it generally indicates a more system related issue, which may or may not be temporary (see examples above).
Prerequisites
- You know How to set up a solution.
- You know How to define the pages and their flow.
- You know How to add parametric inputs to your solution.
1. Setup your solution with model and controls
Let’s start with a solution that contains a model with a single input named value
which is controlled by a corresponding text input in a control panel
kind: Frame
contents:
model:
kind: Model
modelFile: model.gh
subscribe:
- kind: ControlPanel
frame: main
source: controls
controls:
kind: ControlPanel
controls:
value:
kind: TextInput
placeholder: Please provide a value
2. Add the snack bar
When this model fails we would like to inform the user of this. To do this we can add a SnackBar
block and subscribe it to the model error
status:
message:
kind: SnackBar
subscribe:
- kind: Model
frame: main
source: model
onStatus: error
message:
kind: StaticMessage
message: The model failed to solve
Of course the message displayed may be customized to your needs to better inform the user.
In the event of a model error the user will see the following message:

Configuration
See the SnackBar block documentation for more information.