SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exception.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 ///
31 ///@file Exception.h
32 ///@brief Base class for all SCI Exceptions
33 ///
34 ///@author
35 /// Steven G. Parker
36 /// Department of Computer Science
37 /// University of Utah
38 ///@date July 1999
39 ///
40 
41 #ifndef Core_Exceptions_Exception_h
42 #define Core_Exceptions_Exception_h
43 
44 #include <string>
45 #include <Core/Utils/Exception.h>
46 #include <sci_defs/error_defs.h>
47 #include <Core/Exceptions/share.h>
48 
49 #ifdef WIN32 //VS2010 doesn't understand this yet. VS2012 ought to.
50 #define NOEXCEPT
51 #else
52 #define NOEXCEPT noexcept(true)
53 #endif
54 
55 namespace SCIRun {
56  class SCISHARE Exception : public std::exception
57  {
58  public:
59  Exception();
60  virtual ~Exception() NOEXCEPT;
61  virtual const char* message() const=0;
62  virtual const char* type() const=0;
63  const char* stackTrace() const {
64  return stacktrace_;
65  }
66 
67  const char* what() const throw()
68  {
69  return message();
70  }
71 
72  static void sci_throw(const Exception& exc);
73  static bool alwaysFalse();
74  protected:
75  const char* stacktrace_;
76  private:
77  Exception& operator=(const Exception&);
78  };
79 
80  SCISHARE std::string getStackTrace(void* context = 0);
81 } // End namespace SCIRun
82 
83 
84 #if USE_SCI_THROW
85 #define SCI_THROW(exc) do {SCIRun::Exception::sci_throw(exc);throw exc;} while(SCIRun::Exception::alwaysFalse())
86 #else
87 #define SCI_THROW(exc) BOOST_THROW_EXCEPTION(exc)
88 #endif
89 
90 #endif
const char * stackTrace() const
Definition: Exception.h:63
#define SCISHARE
Definition: share.h:39
#define NOEXCEPT
Definition: Exception.h:52
std::string getStackTrace(void *context)
Definition: Exception.cc:195
const char * what() const
Definition: Exception.h:67
Definition: Exception.h:56
const char * stacktrace_
Definition: Exception.h:75