Skip to content

Get cURL error code #78

@dwill20

Description

@dwill20

I haven't found a way to get cURL error code so far. When using EasyInit, it's returning error message string like curl: Couldn't resolve host name.

func main() {
        easy := curl.EasyInit()
	defer easy.Cleanup()

	easy.Setopt(curl.OPT_URL, "http://zzzzzzzz---.com")

	if err := easy.Perform(); err != nil {
		fmt.Println(err, err.Error())
	}
}

But, how to get the cURL error code like the libcurl equivalent returns.

int main(int argc, char *argv[]) {
    CURL *easyhandle = curl_easy_init();
    curl_easy_setopt(easyhandle, CURLOPT_URL, "http://zzzzzzzz---.com");
    int errorCode = curl_easy_perform(easyhandle);
    printf("Error Code: %d %d\n", errorCode, errorCode == CURLE_COULDNT_RESOLVE_HOST);
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions