The reason it works for sending but does not send .error is because the send event is fired internally in the controller (see Zend \ Mvc \ Controller \ AbstractController :: dispatch)
As you extend this class with your own name controller, you can associate an event with this namespace.
However, the dispatch.error event can be raised before the controller (and with it the context of your namespace) is loaded. This happens according to more than one condition in Zend \ Mvc \ DispatchListener.
To set up dispatch.error handling, you will most likely need to write a custom listener for this event, or even write your own dispatch manager (although I would recommend this). You can then take a look at routeMatch to find out what you want to do next. If you use ModuleRouteListener, this can be pretty easy.
source share