Command error middleware