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 #include <string>
11 
12 // Exceptions are conformant ot Fault Code Interoperability, version 20010516.
13 // http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
14 namespace iqxmlrpc
15 {
16 
17 #ifdef _MSC_VER
18 #pragma warning(push)
19 #pragma warning(disable: 4275)
20 #endif
21 
23 class LIBIQXMLRPC_API Exception: public std::runtime_error {
24  int ex_code;
25 
26 public:
27  Exception( const std::string& i, int c = -32000 /*undefined error*/ ):
28  runtime_error( i ), ex_code(c) {}
29 
30  virtual int code() const { return ex_code; }
31 };
32 
33 #ifdef _MSC_VER
34 #pragma warning(pop)
35 #endif
36 
38 class LIBIQXMLRPC_API Parse_error: public Exception {
39 public:
40  Parse_error( const std::string& d ):
41  Exception(std::string("Parser error. ") += d, -32700) {}
42 };
43 
45 class LIBIQXMLRPC_API XmlBuild_error: public Exception {
46 public:
47  XmlBuild_error( const std::string& d ):
48  Exception(std::string("XML build error. ") += d, -32705) {}
49 };
50 
51 #ifdef _MSC_VER
52 #pragma warning(push)
53 #pragma warning(disable: 4275)
54 #endif
55 
57 class LIBIQXMLRPC_API XML_RPC_violation: public Exception {
58 public:
60  Exception("Server error. XML-RPC violation.", -32600) {}
61 
62  XML_RPC_violation( const std::string& s ):
63  Exception(std::string("Server error. XML-RPC violation: ") += s, -32600) {}
64 };
65 
68 class LIBIQXMLRPC_API Unknown_method: public Exception {
69 public:
70  Unknown_method( const std::string& name ):
71  Exception((std::string("Server error. Method '") += name) += "' not found.", -32601) {}
72 };
73 
75 class LIBIQXMLRPC_API Invalid_meth_params: public Exception {
76 public:
78  Exception( "Server error. Invalid method parameters.", -32602 ) {}
79 };
80 
83 class LIBIQXMLRPC_API Fault: public Exception {
84 public:
85  Fault( int c, const std::string& s ):
86  Exception(s, c) {}
87 };
88 
89 #ifdef _MSC_VER
90 #pragma warning(pop)
91 #endif
92 
93 } // namespace iqxmlrpc
94 
95 #endif
Invalid method parameters exception.
Definition: except.h:75
XML Parser error.
Definition: except.h:38
XML-RPC structures not conforming to spec.
Definition: except.h:57
Definition: except.h:68
Base class for iqxmlrpc exceptions.
Definition: except.h:23
XML Parser error.
Definition: except.h:45
Definition: except.h:83