summaryrefslogtreecommitdiffstats
path: root/src/2geom/exception.h
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-11-17 23:52:33 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-11-17 23:52:33 +0000
commit677739f03f65d5f9fa59df15b7306e9dbebc7fbe (patch)
tree5a8dc3dcc6a6d3fa661e77c2c839af13cd2f1e28 /src/2geom/exception.h
parentMerged from Poppler's Gfx.cc; Unset the font if it doesn't exist or we can no... (diff)
downloadinkscape-677739f03f65d5f9fa59df15b7306e9dbebc7fbe.tar.gz
inkscape-677739f03f65d5f9fa59df15b7306e9dbebc7fbe.zip
Fix exception catching, to allow polymorphism. Note to all: always catch by reference! 17.7 of C++FAQlite
(bzr r4099)
Diffstat (limited to 'src/2geom/exception.h')
-rw-r--r--src/2geom/exception.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/2geom/exception.h b/src/2geom/exception.h
index bd950726f..1a031cab9 100644
--- a/src/2geom/exception.h
+++ b/src/2geom/exception.h
@@ -31,6 +31,7 @@
*/
#include <exception>
+#include <sstream>
#include <string>
namespace Geom {
@@ -39,19 +40,15 @@ namespace Geom {
class Exception : public std::exception {
public:
Exception(const char * message, const char *file, const int line)
- : msgstr("Exception thrown: ")
{
- msgstr += message;
- msgstr += " (";
- msgstr += file;
- msgstr += ":";
- msgstr += line;
- msgstr += ")";
+ std::ostringstream os;
+ os << "lib2geom exception: " << message << " (" << file << ":" << line << ")";
+ msgstr = os.str();
}
virtual ~Exception() throw() {} // necessary to destroy the string object!!!
- virtual const char * what() const throw (){
+ virtual const char* what() const throw (){
return msgstr.c_str();
}
protected: