Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Exceptions in sepple

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:


#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?

Name: Anonymous 2009-08-28 20:17

>>1
good pattern
Does. Not. Compute.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List