Stratigility does not provide routing capabilities; it is a middleware dispatching library, full stop.
For handling errors, we already have
Zend\Expressive\Middleware\ErrorHandler, which provides a way both to report errors as well as log them; the reporting capabilities can be customized (see the docs), allowing you to respond in HTML, JSON, XML, or any other format you want.
For routing, we provide zend-expressive-router, which provides a router interface for handling PSR-7 requests and matching them to middleware. zend-expressive has built-in routing middleware that then consumes it, and separate dispatch middleware that actually dispatches the matched middleware.
Finally, when all is said and done, if unable to match a route, we pipe in a “NotFoundHandler”, which returns a templated 404 response.
What you provide above we feel is outside the scope of Stratigility, but fully within the scope of Expressive (which is a middleware framework), and is very similar to how we handle it there.