matlabexception.h
Go to the documentation of this file.
1 // Copyright (C) 2007 Peter Carbonetto. All Rights Reserved.
2 // This code is published under the Eclipse Public License.
3 //
4 // Author: Peter Carbonetto
5 // Dept. of Computer Science
6 // University of British Columbia
7 // May 19, 2007
8 
9 #ifndef INCLUDE_MATLABEXCEPTION
10 #define INCLUDE_MATLABEXCEPTION
11 
12 #include <exception>
13 
14 // Class MatlabException
15 // -----------------------------------------------------------------
16 // It is assumed that the argument passed to the constructor persists
17 // as long as the MatlabException object is in scope. Usually, this
18 // means that it should persist for the duration of the entire
19 // program. This is always the case if the input "message" is a literal.
20 class MatlabException : public std::exception {
21 public:
22  MatlabException (const char* message) throw();
23  ~MatlabException() throw() { };
24 
25  // The copy constructor makes a shallow copy.
26  MatlabException (const MatlabException& source) throw();
27 
28  // The copy assignment operator makes a shallow copy as well.
30 
31  // Return the message string.
32  virtual const char* what () const throw() { return message; };
33 
34  private:
35  const char* message; // The error message.
36 };
37 
38 #endif