1 #ifndef ERIS_EXCEPTIONS_H
2 #define ERIS_EXCEPTIONS_H
3 
4 #include <Atlas/Objects/Root.h>
5 #include <Atlas/Objects/SmartPtr.h>
6 
7 #include <string>
8 #include <stdexcept>
9 
10 namespace Eris
11 {
12 
13 /**
14 This is the Eris base for all exceptions; note it inherits from std::except,
15 which isn't ideal. One option would be to refactor the various final
16 exceptions so they inherit from the 'closest' ISO C++ exception, but it
17 hardly seems worth it.
18 */
19 class BaseException : public std::runtime_error
20 {
21 public:
BaseException(const std::string & m)22 	BaseException(const std::string &m) :
23 		std::runtime_error(m), _msg(m) {;}
24         virtual ~BaseException() throw();
25 	const std::string _msg;
26 };
27 
28 class InvalidOperation : public BaseException
29 {
30 public:
InvalidOperation(const std::string & m)31 	InvalidOperation(const std::string &m) : BaseException(m) {;}
32         virtual ~InvalidOperation() throw();
33 };
34 
35 /// Exception used to indicated malformed or unexpected Atlas from the server
36 class InvalidAtlas : public BaseException
37 {
38 public:
39     InvalidAtlas(const std::string& msg, const Atlas::Objects::Root& obj);
40 
41     InvalidAtlas(const std::string& msg, const Atlas::Message::Element& el);
42 
43     virtual ~InvalidAtlas() throw();
44 private:
45     Atlas::Objects::Root m_obj;
46 };
47 
48 class NetworkFailure : public BaseException
49 {
50 public:
NetworkFailure(const std::string & s)51 	NetworkFailure(const std::string &s) :
52 		BaseException(s) {;}
53         virtual ~NetworkFailure() throw();
54 };
55 
56 }
57 
58 #endif
59