Middlewares to handle client request errors