| 1 | /************************************************************************* |
| 2 | * libjson-rpc-cpp |
| 3 | ************************************************************************* |
| 4 | * @file errors.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_ERRORS_H_ |
| 11 | #define JSONRPC_CPP_ERRORS_H_ |
| 12 | |
| 13 | #include <map> |
| 14 | #include <string> |
| 15 | |
| 16 | #include "jsonparser.h" |
| 17 | |
| 18 | namespace jsonrpc { |
| 19 | class JsonRpcException; |
| 20 | |
| 21 | class Errors { |
| 22 | public: |
| 23 | /** |
| 24 | * @return error message to corresponding error code. |
| 25 | */ |
| 26 | static std::string GetErrorMessage(int errorCode); |
| 27 | |
| 28 | static class _init { |
| 29 | public: |
| 30 | _init(); |
| 31 | } _initializer; |
| 32 | |
| 33 | /** |
| 34 | * Official JSON-RPC 2.0 Errors |
| 35 | */ |
| 36 | static const int ERROR_RPC_JSON_PARSE_ERROR; |
| 37 | static const int ERROR_RPC_METHOD_NOT_FOUND; |
| 38 | static const int ERROR_RPC_INVALID_REQUEST; |
| 39 | static const int ERROR_RPC_INVALID_PARAMS; |
| 40 | static const int ERROR_RPC_INTERNAL_ERROR; |
| 41 | |
| 42 | /** |
| 43 | * Server Library Errors |
| 44 | */ |
| 45 | static const int ERROR_SERVER_PROCEDURE_IS_METHOD; |
| 46 | static const int ERROR_SERVER_PROCEDURE_IS_NOTIFICATION; |
| 47 | static const int ERROR_SERVER_PROCEDURE_POINTER_IS_NULL; |
| 48 | static const int ERROR_SERVER_PROCEDURE_SPECIFICATION_NOT_FOUND; |
| 49 | static const int ERROR_SERVER_PROCEDURE_SPECIFICATION_SYNTAX; |
| 50 | static const int ERROR_SERVER_CONNECTOR; |
| 51 | |
| 52 | /** |
| 53 | * Client Library Errors |
| 54 | */ |
| 55 | static const int ERROR_CLIENT_CONNECTOR; |
| 56 | static const int ERROR_CLIENT_INVALID_RESPONSE; |
| 57 | |
| 58 | private: |
| 59 | static std::map<int, std::string> possibleErrors; |
| 60 | }; |
| 61 | } /* namespace jsonrpc */ |
| 62 | #endif /* JSONRPC_CPP_ERRORS_H_ */ |
| 63 | |