Code: Select all
try{
...
}catch(CEGUI::Exception& e){
...cegui-handler...
}catch(std::exception& e){
...all-other-std-derived-handler...
}
Maybe something as simple as (note I haven't tested this):
Code: Select all
diff --git a/CEGUI/include/CEGUIExceptions.h b/CEGUI/include/CEGUIExceptions.h
--- a/CEGUI/include/CEGUIExceptions.h
+++ b/CEGUI/include/CEGUIExceptions.h
@@ -52,7 +52,10 @@
\brief
Root exception class used within the GUI system.
*/
- class CEGUIEXPORT Exception
+ class CEGUIEXPORT Exception
+#ifdef CEGUI_STD_EXCEPTION
+ :public std::exception
+#endif
{
public:
@@ -71,6 +74,15 @@
/*!
\brief
+ Return a c-string describing the exception being thrown.
+
+ \return
+ c-string containing a message describing the exception.
+ */
+ virtual const char* what() const;
+
+ /*!
+ \brief
Return a reference to the String object describing the reason for the exception being thrown.
\return
@@ -136,6 +148,12 @@
/*!
\brief
+ Holds the default error message.
+ */
+ String d_what;
+
+ /*!
+ \brief
Holds the reason for the exception being thrown.
*/
String d_message;
Code: Select all
diff --git a/CEGUI/src/CEGUIExceptions.cpp b/CEGUI/src/CEGUIExceptions.cpp
--- a/CEGUI/src/CEGUIExceptions.cpp
+++ b/CEGUI/src/CEGUIExceptions.cpp
@@ -52,7 +52,9 @@
Exception::Exception(const String& message, const String& name, const String& filename, int line)
: d_message(message), d_filename(filename), d_name(name), d_line(line)
{
+ d_what = name + " in file " + filename + "(" + PropertyHelper::intToString(line) + ") : " + message;
+
// Log exception or send it to error stream (if logger not available)
Logger* logger = Logger::getSingletonPtr();
if (logger)
{
@@ -55,8 +57,8 @@
// Log exception or send it to error stream (if logger not available)
Logger* logger = Logger::getSingletonPtr();
if (logger)
{
- logger->logEvent(name + " in file " + filename + "(" + PropertyHelper::intToString(line) + ") : " + message, Errors);
+ logger->logEvent(d_what, Errors);
}
else
{
@@ -60,7 +62,7 @@
}
else
{
- std::cerr << name << " in file " << filename.c_str() << "(" << line << ") : " << message.c_str() << std::endl;
+ std::cerr << d_what.c_str() << std::endl;
}
}
@@ -69,4 +71,9 @@
{
}
+ const char* Exception::what() const
+ {
+ return d_what.c_str();
+ }
+
} // End of CEGUI namespace section