add default middleware for handling 404/5xx errors