I see that CURLMBS has
I want to be sure I catch all errors - is it sufficient to just verify Lasterror=0?
What’s the difference between LasterrorMessage and LasterrorText? I notice that some errors produce only one of these.
Usually you check the result from Perform function. That is also put into LastError.
LasterrorMessage is a text provided by CURL about the last error that happened in a transfer.
Many functions like Perform set LastError property. And LastErrorText is looked up text message for that error number.
e.g. if you run
Dim d As New CURLSMBS
d.OptionURL = "http://test.test"
Dim r As Integer = d.Perform
Dim Lasterror As Integer = d.Lasterror
Dim LasterrorText As String = d.LasterrorText
Dim LasterrorMessage As String = d.LasterrorMessage
Then e and r as both 6, the error number for a host resolve problem.
LastErrorText is the looked up description for error 6: Couldn’t resolve host name
But LastErrorMessage is the error message from CURL, which has context information: Could not resolve host: test.test
Anyway, if the transfer is FTP or HTTP, check also GetInfoResponseCode to get the status code there.
Perform returns error --> transport failure
GetInfoResponseCode for HTTP transfer is < 200 or >= 300: HTTP protocol error
OK, thanks. For some Lasterror values (for example I think 3), LasterrorMessage is empty, but LasterrorText has information, so it is not enough to report only LasterrorMessage. I think I will just report both, to be sure.
if LasterrorMessage is empty, use LasterrorText.
I just concatenate them for simpler code
you can do something like this:
dim Message as string = curl.LastErrorMessage
Message = if(Message.len = 0, curl.LastErrorText, Message)
and have it in two lines.