def handle_http_error(exception)
      @last_http_response = exception.response
      case exception
      when RestClient::ResourceNotFound
        # other methods catch this and report more details
        raise exception
      when RestClient::Conflict
        err = JSS::ConflictError
        msg_matcher = /<p>Error:(.*)(<|$)/m
      when RestClient::BadRequest
        err = JSS::BadRequestError
        msg_matcher = %r{>Bad Request</p>\n<p>(.*?)</p>\n<p>You can get technical detail}m
      when RestClient::Unauthorized
        raise
      else
        err = JSS::APIRequestError
        msg_matcher = %r{<body.*?>(.*)</body>}m
      end
      exception.http_body =~ msg_matcher
      msg = Regexp.last_match(1)
      msg ||= exception.http_body
      raise err, msg
    end
def handle_http_error(exception)
      @last_http_response = exception.response
      case exception
      when RestClient::ResourceNotFound
        # other methods catch this and report more details
        raise exception
      when RestClient::Conflict
        err = JSS::ConflictError
        msg_matcher = /<p>Error:(.*)(<|$)/m
      when RestClient::BadRequest
        err = JSS::BadRequestError
        msg_matcher = %r{>Bad Request</p>\n<p>(.*?)</p>\n<p>You can get technical detail}m
      when RestClient::Unauthorized
        raise
      else
        err = JSS::APIRequestError
        msg_matcher = %r{<body.*?>(.*)</body>}m
      end
      exception.http_body =~ msg_matcher
      msg = Regexp.last_match(1)
      msg ||= exception.http_body
      raise err, msg
    end
Parses the HTTP body of a RestClient::ExceptionWithResponse
 (the parent of all HTTP error responses) and its subclasses
 and re-raises a JSS::APIError with a more
 useful error message.

 @param exception[RestClient::ExceptionWithResponse] the exception to parse

 @return [void]