Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Exceptions.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/excn/Exceptions.hh
11 /// @brief common derived classes for thrown exceptions
12 /// @author Oliver Lange
13 
14 
15 #ifndef INCLUDED_utility_excn_Exceptions_HH
16 #define INCLUDED_utility_excn_Exceptions_HH
17 
18 
19 // Unit Headers
21 
23 
24 // Package Headers
25 #include <string>
26 #include <ostream>
27 
28 namespace utility {
29 namespace excn {
30 
31 /* *********************************************************************************************************
32 ************************************************************************************************************
33 ********************* *********************
34 ********************* W A R N I N G *********************
35 ********************* *********************
36 ************************************************************************************************************
37 ************************************************************************************************************
38 Please wait until this note is gone before you start using this interface
39 so far it is very experimental and should remain fluid.
40 We will have something definite soon. bug us per email if you need to know details
41 Oliver <olange@u.washington.edu>
42 Matthew O'Meara <mattjomeara@gmail.com>
43 
44 
45 generally:
46 include files will be found in
47 /<namespace>/Exceptions.hh
48 for specialized Exceptions e.g. a EXCN_InvalidFoldTree
49 
50 all-purpose exceptions are all bundled together in this header.
51 if this gets to big we will have extra forward declarations in Exceptions.fwd.hh
52 
53 ************************************************************************************************************
54 ************************************************************************************************************
55 */
56 
57 class EXCN_Exception : public EXCN_Base {
58 public:
59 
60 };
61 
63 public:
64  EXCN_Msg_Exception( std::string const& msg ) : msg_( msg ) {};
65  virtual void show( std::ostream& ) const;
66  virtual std::string const msg() const { return msg_; };
67  virtual void add_msg( std::string const& str ) {
68  msg_ = msg_+"\n"+str;
69  }
70 protected:
72 private:
73  std::string msg_;
74 };
75 
76 class EXCN_IO : public virtual EXCN_Msg_Exception {
77 protected:
78  EXCN_IO() {};
79 };
80 
81 class EXCN_BadInput : public EXCN_IO {
82 public:
83  EXCN_BadInput( std::string const& msg ) : EXCN_Msg_Exception( msg ) {};
84 protected:
86 private:
87 };
88 
89 class EXCN_FileNotFound : public EXCN_IO {
90 public:
91  EXCN_FileNotFound( std::string const& file ) :
92  EXCN_Msg_Exception( "unable to open file " + file ), file_( file ) {};
93 private:
94  std::string file_;
95 };
96 
98 public:
99  EXCN_RangeError( std::string const& msg ) :
100  EXCN_Msg_Exception( msg ) {};
101 private:
102 };
103 
105 public:
106  EXCN_KeyError(std::string const & msg) :
107  EXCN_Msg_Exception( msg ) {};
108 private:
109 };
110 
112 public:
113  EXCN_NullPointer( std::string const& msg ) :
114  EXCN_RangeError( msg ) {};
115 private:
116 };
117 
119 public:
120  EXCN_RosettaScriptsOption( std::string const& msg ) :
121  EXCN_Msg_Exception( msg ) {};
122 private:
123 };
124 
126 public:
127  EXCN_JD2Failure( std::string const& msg ) :
128  EXCN_Msg_Exception( msg ) {};
129 private:
130 };
131 
132 }
133 }
134 
135 #endif
EXCN_NullPointer(std::string const &msg)
Definition: Exceptions.hh:113
virtual void add_msg(std::string const &str)
Definition: Exceptions.hh:67
EXCN_BadInput(std::string const &msg)
Definition: Exceptions.hh:83
Declarations for many of the common exception subclasses.
EXCN_RosettaScriptsOption(std::string const &msg)
Definition: Exceptions.hh:120
EXCN_KeyError(std::string const &msg)
Definition: Exceptions.hh:106
EXCN_FileNotFound(std::string const &file)
Definition: Exceptions.hh:91
EXCN_Msg_Exception(std::string const &msg)
Definition: Exceptions.hh:64
base class for Exception system
virtual void show(std::ostream &) const
Definition: Exceptions.cc:25
EXCN_RangeError(std::string const &msg)
Definition: Exceptions.hh:99
EXCN_JD2Failure(std::string const &msg)
Definition: Exceptions.hh:127
virtual std::string const msg() const
Definition: Exceptions.hh:66