Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpException.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpException.hpp 2023 2011-06-18 18:49:49Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPEXCEPTION_HPP__
10 #define __IPEXCEPTION_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpJournalist.hpp"
14
15 /* This file contains a base class for all exceptions
16 * and a set of macros to help with exceptions
17 */
18
19 namespace Ipopt
20 {
21
57 class IpoptException
58 {
59 public:
63 IpoptException(std::string msg, std::string file_name, Index line_number, std::string type="IpoptException")
64 :
65 msg_(msg),
66 file_name_(file_name),
67 line_number_(line_number),
68 type_(type)
69 {}
70
72 IpoptException(const IpoptException& copy)
73 :
74 msg_(copy.msg_),
75 file_name_(copy.file_name_),
76 line_number_(copy.line_number_),
77 type_(copy.type_)
78 {}
79
81 virtual ~IpoptException()
82 {}
84
86 void ReportException(const Journalist& jnlst,
87 EJournalLevel level = J_ERROR) const
88 {
89 jnlst.Printf(level, J_MAIN,
90 "Exception of type: %s in file \"%s\" at line %d:\n Exception message: %s\n",
91 type_.c_str(), file_name_.c_str(), line_number_, msg_.c_str());
92 }
93
94 const std::string& Message() const
95 {
96 return msg_;
97 }
98
99 private:
109 IpoptException();
110
112 void operator=(const IpoptException&);
114
115 std::string msg_;
116 std::string file_name_;
117 Index line_number_;
118 std::string type_;
119 };
120
121 } // namespace Ipopt
122
123 #define THROW_EXCEPTION(__except_type, __msg) \
124 throw __except_type( (__msg), (__FILE__), (__LINE__) );
125
126 #define ASSERT_EXCEPTION(__condition, __except_type, __msg) \
127 if (! (__condition) ) { \
128 std::string newmsg = #__condition; \
129 newmsg += " evaluated false: "; \
130 newmsg += __msg; \
131 throw __except_type( (newmsg), (__FILE__), (__LINE__) ); \
132 }
133
134 #define DECLARE_STD_EXCEPTION(__except_type) \
135 class __except_type : public Ipopt::IpoptException \
136 { \
137 public: \
138 __except_type(std::string msg, std::string fname, Ipopt::Index line) \
139 : Ipopt::IpoptException(msg,fname,line, #__except_type) {} \
140 __except_type(const __except_type& copy) \
141 : Ipopt::IpoptException(copy) {} \
142 private: \
143 __except_type(); \
144 void operator=(const __except_type&); \
145 }
146
147 #endif
Ipopt::IpoptException::type_
std::string type_
Definition: IpException.hpp:118
IpUtils.hpp
Ipopt::IpoptException::Message
const std::string & Message() const
Definition: IpException.hpp:94
Ipopt::IpoptException
This is the base class for all exceptions.
Definition: IpException.hpp:57
Ipopt::J_MAIN
Definition: IpJournalist.hpp:73
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::IpoptException::IpoptException
IpoptException()
Default Constructor.
Ipopt::IpoptException::file_name_
std::string file_name_
Definition: IpException.hpp:116
Ipopt::IpoptException::line_number_
Index line_number_
Definition: IpException.hpp:117
Ipopt::IpoptException::IpoptException
IpoptException(std::string msg, std::string file_name, Index line_number, std::string type="IpoptException")
Constructor.
Definition: IpException.hpp:63
Ipopt::IpoptException::msg_
std::string msg_
Definition: IpException.hpp:115
Ipopt::IpoptException::ReportException
void ReportException(const Journalist &jnlst, EJournalLevel level=J_ERROR) const
Method to report the exception to a journalist.
Definition: IpException.hpp:86
Ipopt::Journalist::Printf
virtual void Printf(EJournalLevel level, EJournalCategory category, const char *format,...) const
Method to print a formatted string.
Ipopt::IpoptException::operator=
void operator=(const IpoptException &)
Overloaded Equals Operator.
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::J_ERROR
Definition: IpJournalist.hpp:54
IpJournalist.hpp
Ipopt::IpoptException::IpoptException
IpoptException(const IpoptException &copy)
Copy Constructor.
Definition: IpException.hpp:72
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
file_name
char * file_name
Definition: IpStdCInterface.h:202
Ipopt::IpoptException::~IpoptException
virtual ~IpoptException()
Default destructor.
Definition: IpException.hpp:81