I have this little piece of front-end code, and I had a little code smell about the handling of errors.  request   .post(('/api/comment/:id/upvote').replace(':id', this.comment.id))      .end(function (err, res) {      if (err) {        log('Fetch error: %s', err);        return classes(targetElement).remove('selected');      }      if (res.status == 401) {        return errorContainer.innerHTML = t(res.body.error);      }      if (!res.ok) {        log('Fetch error: %s', res.error);        return classes(targetElement).remove('selected');      }      if (res.body && res.body.error) {        log('Fetch response error: %s', res.body.error);        return classes(targetElement).remove('selected');      }      log('successfull upvote %s', self.comment.id);      });In all error conditions, I should rollback an status of html element.classes(targetElement).remove('selected');I can chain all conditions in one if in order to handle errors, but there's still a code smell.Does someone have some ideas on how to wrap this in a better error handling?
Replacing if validations with a better error handling
javascript