in Education by
I am working on a C++ program, which uses cURL library, which is written in plain C. When I try to connect to an incorrect URL address with cURL handle I get such an exception : terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct NULL not valid and my program terminates instead of skipping this URL and going futher. Here is snippet of my code: CURL* curl; curl_easy_setopt( curl, CURLOPT_URL, "incorrect URL" ); curl_easy_perform( curl ); // this method throws the expection I tried to handle it like this : try{ curl_easy_perform( curl ); } catch { std::logic_error &e){ return -1; // skip this URL and go futher } But still program terminates and it seems that exception is not handled properly. The file "stdexcept" is included. Does anyone knows some more about this error and how to catch this exception properly so I my program can keep on working? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I'm not a libcurl expert, but don't you need to assign the result of curl_easy_init() to your curl variable before calling the next two curl functions? ETA, the following code does not throw an exception for me. The curl_easy_perform return is CURLE_COULDNT_RESOLVE_HOST (6). #include #include int main() { CURL* curl = curl_easy_init(); std::cout << curl_easy_setopt(curl, CURLOPT_URL, "incorrect URL") << std::endl; std::cout << curl_easy_perform(curl) <<std::endl; }

Related questions

0 votes
    How can I write a try/except block that catches all exceptions? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Which of these class is related to all the exceptions that can be caught by using catch? (a) Error (b) ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    A couple months ago I did a project in C++ with Visual Studio that I needed pthreads for, so I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    When does Exceptions in Java arises in code sequence? (a) Run Time (b) Compilation Time (c) Can Occur ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these keywords must be used to monitor for exceptions? (a) try (b) finally (c) throw (d) ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of the following classes can catch all exceptions which cannot be caught? (a) RuntimeException (b) Error (c ... Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these class is related to all the exceptions that cannot be caught? (a) Error (b) Exception (c ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these class is related to all the exceptions that are explicitly thrown? (a) Error (b) Exception ... Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these clause will be executed even if no exceptions are found? (a) throws (b) finally (c) ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these exceptions handles the divide by zero error? (a) ArithmeticException (b) MathException (c) ... Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these keywords are used for the block to be examined for exceptions? (a) try (b) catch (c) ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these keywords are used for the block to handle the exceptions generated by try block? (a) try ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these classes is used to define exceptions? (a) Exception (b) Throwable (c) Abstract (d) System ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What's the proper way to declare custom exception classes in modern Python? My primary goal is to follow whatever ... is it necessary? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    When you just want to do a try-except without handling the exception, how do you do it in Python? Is the ... rmtree(path) except: pass Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
...