/usr/include/curlpp/Exception.hpp is in libcurlpp-dev 0.7.3-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | /*
* Copyright (c) <2002-2009> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (curlpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef CURLPP_EXCEPTION_HPP
#define CURLPP_EXCEPTION_HPP
#include "internal/buildconfig.h"
#include <curl/curl.h>
#include <string>
#include <stdexcept>
namespace curlpp
{
/**
* This class is a parent to all curlpp's RuntimeErrors.
*
* This class takes a const std::string & as argument for it's parent: std::runtime_errors.
* This class is thrown when curlpp is encountering an error, but for runtime
* considerations, "unpredictable" by the library user.
*/
class CURLPPAPI RuntimeError : public std::runtime_error
{
public:
RuntimeError(const char * reason);
RuntimeError(const std::string & string);
virtual ~RuntimeError() throw();
};
/**
* This class is a parent to all curlpp's RuntimeErrors.
*
* This class takes a const std::string & as argument for it's parent: std::runtime_errors.
* This class is thrown when curlpp is encountering an error, but for logic
* considerations, "predictable" by the library user. Predictable means
* that the library user is missusing the library.
*/
class CURLPPAPI LogicError : public std::logic_error
{
public:
LogicError(const char * reason);
LogicError(const std::string & string);
virtual ~LogicError() throw();
};
/**
* This is a class derived from curlpp::RuntimeError.
*
* It takes a const char * and a CURLcode as arguments. This class is thrown when libcurl is
* returning an error with a CURLcode, but for runtime considerations,
* "unpredictable" by the library user.
*/
class CURLPPAPI LibcurlRuntimeError : public curlpp::RuntimeError
{
public:
LibcurlRuntimeError(const std::string & reason, CURLcode code);
LibcurlRuntimeError(const char * reason, CURLcode code);
/**
* Returns the CURLcode that libcurl returned.
*/
CURLcode whatCode() const throw();
private:
CURLcode mCode;
};
/*
* This is a class derived from curlpp::LogicError, that takes a const
* char * and a CURLcode as arguments. This class is thrown when libcurl is
* returning an error with a CURLcode, but for logic considerations,
* "predictable" by the library user. Predictable means that the library
* user is missusing the library.
*/
class CURLPPAPI LibcurlLogicError : public curlpp::LogicError
{
public:
LibcurlLogicError(const std::string & reason, CURLcode code);
LibcurlLogicError(const char * reason, CURLcode code);
/*
* return the CURLcode that libcurl returned
*/
CURLcode whatCode() const throw();
private:
CURLcode mCode;
};
/**
* This exception is thrown when you try to retreive a value for an
* unset option.
*/
class UnsetOption : public curlpp::RuntimeError
{
public:
CURLPPAPI UnsetOption(const std::string & reason);
CURLPPAPI UnsetOption(const char * reason);
};
/**
* This exception is thrown when you try to instantiate an option
* that isn't available for your current libcURL version.
*/
class NotAvailable : public curlpp::LogicError
{
public:
CURLPPAPI NotAvailable();
};
/**
* This exception is thrown when an exception is thrown within
* a callback without the curlpp::raiseException function.
*/
class UnknowException : public curlpp::RuntimeError
{
public:
CURLPPAPI UnknowException();
};
/**
* This exception is thrown by the curlpp::raiseException function.
* It's used to throw exceptions within callbacks
*/
class CURLPPAPI CallbackExceptionBase : public curlpp::RuntimeError
{
protected:
CallbackExceptionBase();
CallbackExceptionBase(const CallbackExceptionBase & other);
public:
virtual void throwMe() = 0;
virtual CallbackExceptionBase * clone() = 0;
};
/**
* This exception is thrown by the curlpp::raiseException function.
* It's used to throw exceptions within callbacks
*/
template<typename ExceptionType>
class CURLPPAPI CallbackException : public CallbackExceptionBase
{
public:
typedef CallbackException<ExceptionType> _CE;
CallbackException(const ExceptionType & e)
: mException(e)
{}
virtual void throwMe()
{
throw mException;
}
virtual _CE * clone()
{
return new _CE(*this);
}
private:
ExceptionType mException;
};
/**
* This function is the function to be called within callbacks
* if you want an exception to be thrown at the
* curlpp::Easy::perform function call level.
*/
template<typename T>
void raiseException(const T & e)
{
throw (CallbackExceptionBase *)(new CallbackException<T>(e));
}
template<typename T>
CallbackException<T> * createCallbackException(const T & e)
{
return CallbackException<T>(e);
}
/**
* if CURLcode is not equal to CURLE_OK, it throws a
* curlpp::LibcurlRuntimeError with the reason and the code. It's used
* in inline function, because throwing an exception is heavy in binary
* code, something we don't want in inline functions.
*/
void CURLPPAPI libcurlRuntimeAssert(const std::string & reason, CURLcode code);
void CURLPPAPI libcurlRuntimeAssert(const char * reason, CURLcode code);
/**
* if CURLcode is not equal to CURLE_OK, it throws a
* curlpp::LibcurlLogicError with the reason and the code. It's used
* in inline function, because throwing an exception is heavy in binary
* code, something we don't want in inline functions.
*/
void CURLPPAPI libcurlLogicAssert(const std::string & reason, CURLcode code);
void CURLPPAPI libcurlLogicAssert(const char * reason, CURLcode code);
/**
* if isOkay is false, it throws a curlpp::RuntimeError
* with the reason. It's used in inline function, because throwing
* an exception is heavy in binary code, something we don't want in
* an inline function.
*/
void CURLPPAPI runtimeAssert(const std::string & reason, bool isOkay);
void CURLPPAPI runtimeAssert(const char * reason, bool isOkay);
/**
* if is_true is false, it throws a curlpp::LogicError with
* the reason. It's used in inline function, because throwing
* an exception is heavy in binary code, something we don't
* want in an inline function.
*/
void CURLPPAPI logicAssert(const std::string & reason, bool isOkay);
void CURLPPAPI logicAssert(const char * reason, bool isOkay);
} // namespace curlpp
namespace cURLpp = curlpp;
#endif // #ifndef CURLPP_EXCEPTION_HPP
|