@@ -98,11 +98,21 @@ namespace curl {
98
98
* This constructor allows to specify a custom error message and the method name where
99
99
* the exception has been thrown.
100
100
*/
101
- curl_easy_exception (const std::string &error, const std::string &method) : curl_exception(error,method) {}
101
+ curl_easy_exception (const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLE_OK) {}
102
102
/* *
103
103
* The constructor will transform a CURLcode error in a proper error message.
104
104
*/
105
- curl_easy_exception (const CURLcode &code, const std::string &method) : curl_exception(curl_easy_strerror(code),method) {}
105
+ curl_easy_exception (const CURLcode &code, const std::string &method) : curl_exception(curl_easy_strerror(code),method), code(code) {}
106
+
107
+ /* *
108
+ * Returns the error code if there is one. Returns CURLE_OK if none has been set.
109
+ */
110
+ inline CURLcode get_code () const {
111
+ return code;
112
+ }
113
+
114
+ private:
115
+ CURLcode code;
106
116
};
107
117
108
118
/* *
@@ -115,11 +125,21 @@ namespace curl {
115
125
* This constructor enables setting a custom error message and the method name where
116
126
* the exception has been thrown.
117
127
*/
118
- curl_multi_exception (const std::string &error, const std::string &method) : curl_exception(error,method) {}
128
+ curl_multi_exception (const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLM_OK) {}
119
129
/* *
120
130
* The constructor will transform a CURLMcode error to a proper error message.
121
131
*/
122
- curl_multi_exception (const CURLMcode code, const std::string &method) : curl_exception(curl_multi_strerror(code),method) {}
132
+ curl_multi_exception (const CURLMcode code, const std::string &method) : curl_exception(curl_multi_strerror(code),method), code(code) {}
133
+
134
+ /* *
135
+ * Returns the error code if there is one. Returns CURLM_OK if none has been set.
136
+ */
137
+ inline CURLMcode get_code () const {
138
+ return code;
139
+ }
140
+
141
+ private:
142
+ CURLMcode code;
123
143
};
124
144
125
145
/* *
@@ -132,11 +152,21 @@ namespace curl {
132
152
* This constructor enables setting a custom error message and the method name where
133
153
* the exception has been thrown.
134
154
*/
135
- curl_share_exception (const std::string &error, const std::string &method) : curl_exception(error,method) {}
155
+ curl_share_exception (const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLSHE_OK) {}
136
156
/* *
137
157
* The constructor will transform a CURLSHcode error in a proper error message.
138
158
*/
139
- curl_share_exception (const CURLSHcode code, const std::string &method) : curl_exception(curl_share_strerror(code),method) {}
159
+ curl_share_exception (const CURLSHcode code, const std::string &method) : curl_exception(curl_share_strerror(code),method), code(code) {}
160
+
161
+ /* *
162
+ * Returns the error code if there is one. Returns CURLE_OK if none has been set.
163
+ */
164
+ inline CURLSHcode get_code () const {
165
+ return code;
166
+ }
167
+
168
+ private:
169
+ CURLSHcode code;
140
170
};
141
171
}
142
172
0 commit comments