Ipopt
3.11.4
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
src
Common
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
Generated on Mon Oct 21 2013 19:08:15 for Ipopt by
1.8.4