afterErrorHook is not middleware.