Name: Anonymous 2009-08-28 17:44
How do you manage exceptions in sepple? I experimented this some time ago. I thought it was a good pattern, but it led me to death:
Used as follows:
What do you think about it?
#include <exception>
#include <string>
using namespace std;
/* This one is used for exceptions in memory management */
class MemoryException : public exception {
private:
string error;
public:
const char *what() {
return error.c_str()
}
virtual ~MemoryException() throw() {};
MemoryException &setError(string e) {
error = e;
return *this;
}
};Used as follows:
class HowAreYou {
private:
MemoryException error;
public:
void some_failing_method() throw (MemoryException) {
throw error.setError("Oh, crap, I failed!");
}
}What do you think about it?