escript  Revision_
EsysException.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 #ifndef __ESCRIPT_ESYSEXCEPTION_H__
19 #define __ESCRIPT_ESYSEXCEPTION_H__
20 
21 #include <exception>
22 #include <string>
23 #include <iostream>
24 
25 namespace escript {
26 
30 class EsysException : public std::exception
31 {
32 public:
39  EsysException(const std::string& message) : msg(message)
40  {
41 #if 1 // for debug on windows
42 #ifdef _WIN32
43  std::cerr << std::endl << "EsysException:" << std::endl
44  << message << std::endl << std::endl
45  << std::flush;
46 #endif
47 #endif
48  }
49 
51  virtual ~EsysException() throw() {}
52 
57  inline virtual const char* what() const throw() { return msg.c_str(); }
58 
59 private:
60  //
61  // the exception message
62  std::string msg;
63 };
64 
70 {
71 public:
72  AssertException(const std::string& str) : EsysException(str) {}
73 };
74 
79 class IOError : public EsysException
80 {
81 public:
82  IOError(const std::string& str) : EsysException(str) {}
83 };
84 
90 {
91 public:
92  NotImplementedError(const std::string& str) : EsysException(str) {}
93 };
94 
99 class ValueError : public EsysException
100 {
101 public:
102  ValueError(const std::string& str) : EsysException(str) {}
103 };
104 
105 } // namespace escript
106 
107 #endif // __ESCRIPT_ESYSEXCEPTION_H__
108 
escript::EsysException::msg
std::string msg
Definition: EsysException.h:62
message
Definition: blocktools.h:70
escript::EsysException
The base class for escript exceptions.
Definition: EsysException.h:31
escript::NotImplementedError
An exception class for features which are not (yet) implemented.
Definition: EsysException.h:90
escript::EsysException::~EsysException
virtual ~EsysException()
Destructor.
Definition: EsysException.h:51
escript::ValueError::ValueError
ValueError(const std::string &str)
Definition: EsysException.h:102
escript::IOError
An exception class for Input/Output errors.
Definition: EsysException.h:80
escript::AssertException
An exception class for assertions within escript.
Definition: EsysException.h:70
escript::NotImplementedError::NotImplementedError
NotImplementedError(const std::string &str)
Definition: EsysException.h:92
escript::EsysException::EsysException
EsysException(const std::string &message)
Constructor which creates an Exception with the given message.
Definition: EsysException.h:39
escript::IOError::IOError
IOError(const std::string &str)
Definition: EsysException.h:82
escript::AssertException::AssertException
AssertException(const std::string &str)
Definition: EsysException.h:72
escript
Definition: AbstractContinuousDomain.cpp:23
escript::EsysException::what
virtual const char * what() const
Returns a description of the exception.
Definition: EsysException.h:57
escript::ValueError
An exception class that signals an invalid argument value.
Definition: EsysException.h:100