DRY error response handling