Skip to content

Scarce error information. Failed to query. Status code -1 #153

@et-nik

Description

@et-nik

I think need to add more details when an error occurs. If restclient couldn't connect to the host or resolve the domain, then there is almost no information. There is only an uninformative error 'Failed to query' and -1 status code.

Curl library has good functionality about many errors, but it is not used.

https://github.com/mrtazz/restclient-cpp/blob/master/source/connection.cc#L444

Maybe add more curl errors?

switch (res) {
  case CURLE_OPERATION_TIMEDOUT:
    ret.code = res;
    ret.body = "Operation Timeout.";
    break;
  case CURLE_SSL_CERTPROBLEM:
  case CURLE_FAILED_INIT:
  case CURLE_URL_MALFORMAT:
  case CURLE_NOT_BUILT_IN:
  case CURLE_COULDNT_RESOLVE_PROXY:
  case CURLE_COULDNT_RESOLVE_HOST:
  case CURLE_COULDNT_CONNECT:
  // ...
    ret.code = res;
    ret.body = curl_easy_strerror(res);
    break;
  default:
    ret.body = "Failed to query.";
    ret.code = -1;
}

List of all curl error here https://curl.haxx.se/libcurl/c/libcurl-errors.html

If you want, I can create PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions