HermesCommon  3.0
exceptions.h
Go to the documentation of this file.
1 // This file is part of HermesCommon
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __HERMES_COMMON_EXCEPTIONS_H_
23 #define __HERMES_COMMON_EXCEPTIONS_H_
24 
25 #include "common.h"
26 #include "util/compat.h"
27 
28 #ifndef _DEBUG
29 #undef assert
30 #define assert(x)
31 #endif
32 
33 namespace Hermes
34 {
35  namespace Exceptions
36  {
49  class HERMES_API Exception : public std::exception
50  {
51  public:
53  Exception();
54  Exception(const Exception& e);
57  Exception(const char * msg, ...);
59  void print_msg() const;
61  virtual const char * what() const throw();
62  std::string info() const;
64  const char * get_func_name() const;
65  virtual ~Exception() throw() {};
66 
67  protected:
68  std::stringstream message;
70  char message_char[10000];
71  };
72 
76  class HERMES_API IOException : public Exception
77  {
78  public:
80  enum ReadWrite
81  {
82  Read,
83  Write
84  };
88  IOException(ReadWrite readWrite, const char* filename);
89  IOException(ReadWrite readWrite, std::string filename);
90 
91  virtual ~IOException() throw() {};
92  IOException(const IOException & e);
93  private:
94  ReadWrite readWrite;
95  std::string filename;
96  };
97 
101  class HERMES_API NullException : public Exception
102  {
103  public:
105  NullException();
108  NullException(unsigned int param_idx);
112  NullException(unsigned int param_idx, unsigned int item_idx);
114  unsigned int get_param_idx() const;
116  unsigned int get_item_idx() const;
117  virtual ~NullException() throw() {};
118  NullException(const NullException & e);
119  private:
120  unsigned int param_idx, item_idx;
121  };
122 
126  class HERMES_API LengthException : public Exception
127  {
128  public:
130  LengthException();
134  LengthException(unsigned int wrong, unsigned int right);
139  LengthException(unsigned int param_idx, unsigned int wrong, unsigned int right);
145  LengthException(unsigned int fst_param_idx, unsigned int snd_param_idx, unsigned int first, unsigned int second);
147  unsigned int get_first_param_idx() const;
149  unsigned int get_second_param_idx() const;
151  unsigned int get_first_length() const;
153  unsigned int get_expected_length() const;
154  virtual ~LengthException() throw() {};
155  LengthException(const LengthException & e);
156  private:
157  unsigned int fst_param_idx, snd_param_idx, wrong, right;
158  };
159 
161  class HERMES_API LinearMatrixSolverException : public Exception
162  {
163  public:
168  LinearMatrixSolverException(const char * reason, ...);
169  virtual ~LinearMatrixSolverException() throw() {};
171  };
172 
174  class HERMES_API ValueException : public Exception
175  {
176  public:
181  ValueException(const char * name, double value, double allowed);
187  ValueException(const char * name, double value, double min, double max);
189  ValueException(const char * name, std::string passed);
191  double get_value() const;
193  double get_allowed() const;
194  virtual ~ValueException() throw() {};
195  ValueException(const ValueException & e);
196  private:
197  double value, allowed;
198  };
199 
201  class HERMES_API MethodNotOverridenException : public Exception
202  {
203  public:
206  MethodNotOverridenException(const char * msg, ...);
207  virtual ~MethodNotOverridenException() throw() {};
209  };
210 
212  class HERMES_API MethodNotImplementedException : public Exception
213  {
214  public:
217  MethodNotImplementedException(const char * msg, ...);
218  virtual ~MethodNotImplementedException() throw() {};
220  };
221 
224  class HERMES_API MeshLoadFailureException : public Exception
225  {
226  public:
229  MeshLoadFailureException(const char * msg, ...);
230  ~MeshLoadFailureException() throw() {};
232  };
233 
235  class HERMES_API SpaceLoadFailureException : public Exception
236  {
237  public:
240  SpaceLoadFailureException(const char * msg, ...);
241  virtual ~SpaceLoadFailureException() throw() {};
243  };
244 
246  class HERMES_API SolutionSaveFailureException : public Exception
247  {
248  public:
251  SolutionSaveFailureException(const char * msg, ...);
252  virtual ~SolutionSaveFailureException() throw() {};
254  };
255 
257  class HERMES_API SolutionLoadFailureException : public Exception
258  {
259  public:
262  SolutionLoadFailureException(const char * msg, ...);
263  virtual ~SolutionLoadFailureException() throw() {};
265  };
266  }
267 }
268 #endif
General namespace for the Hermes library.
Exception interface Basically a std::exception, but with a constructor with string and with print_msg...
Definition: exceptions.h:49
Parameter length parameter exception. Internal. Exception occurs when some parameter has wrong length...
Definition: exceptions.h:126
Mesh failed to load. Thrown by Hermes2D::MeshReaderH2DXML, MeshReaderH2D.
Definition: exceptions.h:224
IO exception. Internal. Exception occurs when something fails to be written to / read from the disk...
Definition: exceptions.h:76
File containing platform compatibility layer, especially for Win / MSVC.
Null parameter exception. Internal. Exception occurs when some parameter is Null or empty and it shou...
Definition: exceptions.h:101
Method is not overriden and should be.
Definition: exceptions.h:201
File containing common definitions, and basic global enums etc. for HermesCommon. ...
Numeric value is out of allowed range.
Definition: exceptions.h:174
Method is not overriden and should be.
Definition: exceptions.h:212