libiqxmlrpc  0.12.4
 All Classes Namespaces Files Functions Typedefs Enumerations
except.h
1 // Libiqxmlrpc - an object-oriented XML-RPC solution.
2 // Copyright (C) 2011 Anton Dedov
3 
4 #ifndef _iqxmlrpc_except_h_
5 #define _iqxmlrpc_except_h_
6 
7 #include "api_export.h"
8 
9 #include <stdexcept>
10 
11 // Exceptions are conformant ot Fault Code Interoperability, version 20010516.
12 // http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
13 namespace iqxmlrpc
14 {
15 
16 #ifdef _MSC_VER
17 #pragma warning(push)
18 #pragma warning(disable: 4275)
19 #endif
20 
22 class LIBIQXMLRPC_API Exception: public std::runtime_error {
23  int ex_code;
24 
25 public:
26  Exception( const std::string& i, int c = -32000 /*undefined error*/ ):
27  runtime_error( i ), ex_code(c) {}
28 
29  virtual int code() const { return ex_code; }
30 };
31 
32 #ifdef _MSC_VER
33 #pragma warning(pop)
34 #endif
35 
37 class LIBIQXMLRPC_API Parse_error: public Exception {
38 public:
39  Parse_error( const std::string& d ):
40  Exception(std::string("Parser error. ") += d, -32700) {}
41 };
42 
44 class LIBIQXMLRPC_API XmlBuild_error: public Exception {
45 public:
46  XmlBuild_error( const std::string& d ):
47  Exception(std::string("XML build error. ") += d, -32705) {}
48 };
49 
50 #ifdef _MSC_VER
51 #pragma warning(push)
52 #pragma warning(disable: 4275)
53 #endif
54 
56 class LIBIQXMLRPC_API XML_RPC_violation: public Exception {
57 public:
59  Exception("Server error. XML-RPC violation.", -32600) {}
60 
61  XML_RPC_violation( const std::string& s ):
62  Exception(std::string("Server error. XML-RPC violation: ") += s, -32600) {}
63 };
64 
67 class LIBIQXMLRPC_API Unknown_method: public Exception {
68 public:
69  Unknown_method( const std::string& name ):
70  Exception((std::string("Server error. Method '") += name) += "' not found.", -32601) {}
71 };
72 
74 class LIBIQXMLRPC_API Invalid_meth_params: public Exception {
75 public:
77  Exception( "Server error. Invalid method parameters.", -32602 ) {}
78 };
79 
82 class LIBIQXMLRPC_API Fault: public Exception {
83 public:
84  Fault( int c, const std::string& s ):
85  Exception(s, c) {}
86 };
87 
88 #ifdef _MSC_VER
89 #pragma warning(pop)
90 #endif
91 
92 } // namespace iqxmlrpc
93 
94 #endif