Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. class Exception
  2. {
  3. public:
  4. // construction
  5. Exception(int code, const char* format="", ...);
  6. virtual ~Exception(void);
  7.  
  8. <snip - get/set routines and print function>
  9.  
  10. protected:
  11. private:
  12. int mCode; // thrower sets this
  13. char mMessage[Exception::MessageLen]; // thrower says this FIXME: use String
  14. };
  15.  
  16. class Derived : public Exception {
  17. public:
  18. Derived (const char* throwerSays) : Exception(1, throwerSays) {};
  19. };
  20.  
  21. void innercall {
  22. <do stuff>
  23. throw Derived("Bad things happened!");
  24. }
  25.  
  26. void outercall {
  27. try {
  28. innercall();
  29. }
  30. catch(Exception& e)
  31. {
  32. printf("Exception seen here! %s %dn", __FILE__, __LINE__);
  33. throw e;
  34. }
  35. }
  36.  
  37. catch(Exception& e)
  38. {
  39. printf("Exception seen here! %s %dn", __FILE__, __LINE__);
  40. throw;
  41. }
  42.  
  43. throw e;
  44.  
  45. throw;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement