When you quickstart a TG2 project, it will create an ErrorController for you in yourproject/controllers/error.py.
When an unhandled exception is raised in your application, and debugging is turned off, that exception goes all the way up the call stack, to the Error Middleware, which then tries to dispatch your ErrorController to display an error message to the client.
The idea is that you can set up error reporting, templates, whatever you like, for your ErrorController, to fully customize your error handling experience.
This usually works automagically, but it wasn’t working for me, so I decided to figure out how this whole process works.