update error middleware