You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the cpr::Error object converts cURL error codes into cpr::ErrorCode using the cpr::Error::getErrorCodeForCurlError method. However, the original cURL error code is discarded after instantiation, and there is no way to retrieve it.
I ran into this limitation in my project when the public key pinned to a domain was changed unexpectedly by Cloudflare, and the app has stopped connecting to the server all of the sudden. CPR converted the cURL error CURLE_SSL_PINNEDPUBKEYNOTMATCH into cpr::ErrorCode::INTERNAL_ERROR, which did not provide useful information about the underlying issue. In this case, access to the original cURL error would have made it much easier to diagnose the problem.
This is just one example, but it shows that retaining the real cURL error code could be valuable for debugging specific issues.
Possible Solution
I propose adding a property for the real cURL error code to the Error object to allow easy access. This would be helpful in situations where the current conversion to cpr::ErrorCode is too generic and doesn't provide enough information for specific error codes.
@Deatha69 thanks for submitting this suggestion. I agree, the current cpr error codes are too generic. This needs to change. Instead of just forwarding curl error codes, I decided to make cpr error codes far more verbose by adding all missing curl error codes except the ones for unsupported protocols e.g. FTP.
Here is the PR: #1110
@Deatha69 thanks for submitting this suggestion. I agree, the current cpr error codes are too generic. This needs to change. Instead of just forwarding curl error codes, I decided to make cpr error codes far more verbose by adding all missing curl error codes except the ones for unsupported protocols e.g. FTP. Here is the PR: #1110
Does this fulfil your needs?
Looks great! While I wanted to avoid breaking changes, I agree that it didn't really address the lack of error codes in cpr, so I guess it needed to be done. I also doubt there will be many changes to the CURLE enum in the future, and if there are, they likely won’t be significant.
Is your feature request related to a problem?
Currently, the
cpr::Error
object converts cURL error codes intocpr::ErrorCode
using thecpr::Error::getErrorCodeForCurlError
method. However, the original cURL error code is discarded after instantiation, and there is no way to retrieve it.I ran into this limitation in my project when the public key pinned to a domain was changed unexpectedly by Cloudflare, and the app has stopped connecting to the server all of the sudden. CPR converted the cURL error
CURLE_SSL_PINNEDPUBKEYNOTMATCH
intocpr::ErrorCode::INTERNAL_ERROR
, which did not provide useful information about the underlying issue. In this case, access to the original cURL error would have made it much easier to diagnose the problem.This is just one example, but it shows that retaining the real cURL error code could be valuable for debugging specific issues.
Possible Solution
I propose adding a property for the real cURL error code to the Error object to allow easy access. This would be helpful in situations where the current conversion to
cpr::ErrorCode
is too generic and doesn't provide enough information for specific error codes.Alternatives
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: