@@ -51,11 +51,19 @@ namespace curl {
51
51
*/
52
52
class curl_exception : public std ::exception {
53
53
public:
54
-
55
54
/* *
56
55
* This constructor is used to build the error.
57
56
*/
58
57
curl_exception (const std::string&, const std::string&);
58
+ /* *
59
+ * The copy constructor allows to copy the object in a thread safe way.
60
+ */
61
+ curl_exception (const curl_exception &);
62
+ /* *
63
+ * The assignment operator allows to assign the object to another object in
64
+ * a thread safe way.
65
+ */
66
+ curl_exception & operator =(curl_exception &);
59
67
/* *
60
68
* The destructor, in this case, doesn't do anything.
61
69
*/
@@ -73,6 +81,11 @@ namespace curl {
73
81
* Simple method which clears the entire error stack.
74
82
*/
75
83
void clear_traceback () const ;
84
+ /* *
85
+ * Simple method which clears the error stack saving it (before cleaning) in a
86
+ * traceback specified in input.
87
+ */
88
+ void clear_traceback (curlcpp_traceback &) const ;
76
89
private:
77
90
/* *
78
91
* The error container must be static or will be cleared
@@ -88,11 +101,11 @@ namespace curl {
88
101
89
102
// Implementation of print_traceback
90
103
inline void curl_exception::print_traceback () const {
91
- curl_exception::tracebackLocker.lock ();
104
+ curl_exception::tracebackLocker.lock ();
92
105
std::for_each (curl_exception::traceback.begin (),curl_exception::traceback.end (),[](const curlcpp_traceback_object &value) {
93
106
std::cout<<" ERROR: " <<value.first <<" ::::: FUNCTION: " <<value.second <<std::endl;
94
107
});
95
- curl_exception::tracebackLocker.unlock ();
108
+ curl_exception::tracebackLocker.unlock ();
96
109
}
97
110
98
111
// Implementation of clear method.
@@ -101,10 +114,21 @@ namespace curl {
101
114
curl_exception::traceback.clear ();
102
115
curl_exception::tracebackLocker.unlock ();
103
116
}
117
+
118
+ // Implementation of overloaded clear method.
119
+ inline void curl_exception::clear_traceback (curlcpp_traceback& traceback_ref) const {
120
+ curl_exception::tracebackLocker.lock ();
121
+ traceback_ref = curl_exception::traceback;
122
+ curl_exception::traceback.clear ();
123
+ curl_exception::tracebackLocker.unlock ();
124
+ }
104
125
105
126
// Implementation of get_traceback.
106
127
inline curlcpp_traceback curl_exception::get_traceback () const {
107
- return curl_exception::traceback;
128
+ curl_exception::tracebackLocker.lock ();
129
+ curlcpp_traceback tmp = curl_exception::traceback;
130
+ curl_exception::tracebackLocker.unlock ();
131
+ return tmp;
108
132
}
109
133
110
134
/* *
@@ -129,7 +153,6 @@ namespace curl {
129
153
inline CURLcode get_code () const {
130
154
return code;
131
155
}
132
-
133
156
private:
134
157
CURLcode code;
135
158
};
@@ -156,7 +179,6 @@ namespace curl {
156
179
inline CURLMcode get_code () const {
157
180
return code;
158
181
}
159
-
160
182
private:
161
183
CURLMcode code;
162
184
};
@@ -183,7 +205,6 @@ namespace curl {
183
205
inline CURLSHcode get_code () const {
184
206
return code;
185
207
}
186
-
187
208
private:
188
209
CURLSHcode code;
189
210
};
0 commit comments