Show how to add a handler so that the state of the model is dumped when an error occurs.