1 | /************************************************************************* |
2 | * libjson-rpc-cpp |
3 | ************************************************************************* |
4 | * @file exception.h |
5 | * @date 31.12.2012 |
6 | * @author Peter Spiess-Knafl <dev@spiessknafl.at> |
7 | * @license See attached LICENSE.txt |
8 | ************************************************************************/ |
9 | |
10 | #ifndef JSONRPC_CPP_EXCEPTION_H_ |
11 | #define JSONRPC_CPP_EXCEPTION_H_ |
12 | |
13 | #include <exception> |
14 | #include <sstream> |
15 | #include <string> |
16 | |
17 | #include "errors.h" |
18 | |
19 | namespace jsonrpc { |
20 | class JsonRpcException : public std::exception { |
21 | public: |
22 | JsonRpcException(int code); |
23 | JsonRpcException(int code, const std::string &message); |
24 | JsonRpcException(int code, const std::string &message, const Json::Value &data); |
25 | JsonRpcException(const std::string &message); |
26 | |
27 | virtual ~JsonRpcException() throw(); |
28 | |
29 | int GetCode() const; |
30 | const std::string &GetMessage() const; |
31 | const Json::Value &GetData() const; |
32 | |
33 | virtual const char *what() const throw(); |
34 | |
35 | private: |
36 | int code; |
37 | std::string message; |
38 | std::string whatString; |
39 | Json::Value data; |
40 | void setWhatMessage(); |
41 | }; |
42 | |
43 | } /* namespace jsonrpc */ |
44 | #endif /* JSONRPC_CPP_EXCEPTION_H_ */ |
45 | |