HermesCommon  2.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://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 "compat.h"
27 
28 namespace Hermes
29 {
30  namespace Exceptions
31  {
44  class HERMES_API Exception : public std::exception
45  {
46  public:
48  Exception();
51  Exception(const char * msg, ...);
53  void print_msg() const;
55  virtual const char * what() const throw();
57  const char * get_func_name() const;
58  virtual ~Exception() throw() {};
59 
60  virtual Exception* clone();
61  protected:
62  char * message;
63  };
64 
68  class HERMES_API NullException : public Exception
69  {
70  public:
73  NullException(int param_idx);
77  NullException(int param_idx, int item_idx);
79  int get_param_idx() const;
81  int get_item_idx() const;
82  ~NullException() throw() {};
83  NullException(const NullException & e);
84  virtual Exception* clone();
85  private:
86  int param_idx, item_idx;
87  };
88 
92  class HERMES_API LengthException : public Exception
93  {
94  public:
99  LengthException(int param_idx, int wrong, int right);
105  LengthException(int fst_param_idx, int snd_param_idx, int first, int second);
107  int get_first_param_idx() const;
109  int get_second_param_idx() const;
111  int get_first_length() const;
113  int get_expected_length() const;
114  ~LengthException() throw() {};
115  LengthException(const LengthException & e);
116  virtual Exception* clone();
117  private:
118  int fst_param_idx, snd_param_idx, wrong, right;
119  };
120 
122  class HERMES_API LinearMatrixSolverException : public Exception
123  {
124  public:
129  LinearMatrixSolverException(const char * reason);
130  ~LinearMatrixSolverException() throw() {};
132  virtual Exception* clone();
133  };
134 
136  class HERMES_API ValueException : public Exception
137  {
138  public:
143  ValueException(const char * name, double value, double allowed);
149  ValueException(const char * name, double value, double min, double max);
151  ValueException(const char * name, std::string passed);
153  double get_value() const;
155  double get_allowed() const;
156  ~ValueException() throw() {};
157  ValueException(const ValueException & e);
158  virtual Exception* clone();
159  private:
160  double value, allowed;
161  };
162 
164  class HERMES_API MethodNotOverridenException : public Exception
165  {
166  public:
169  MethodNotOverridenException(const char * msg, ...);
170  ~MethodNotOverridenException() throw() {};
172  virtual Exception* clone();
173  };
174 
177  class HERMES_API MeshLoadFailureException : public Exception
178  {
179  public:
182  MeshLoadFailureException(const char * msg, ...);
183  ~MeshLoadFailureException() throw() {};
185  virtual Exception* clone();
186  };
187 
189  class HERMES_API SpaceLoadFailureException : public Exception
190  {
191  public:
194  SpaceLoadFailureException(const char * msg, ...);
195  ~SpaceLoadFailureException() throw() {};
197  virtual Exception* clone();
198  };
199 
201  class HERMES_API SolutionSaveFailureException : public Exception
202  {
203  public:
206  SolutionSaveFailureException(const char * msg, ...);
207  ~SolutionSaveFailureException() throw() {};
209  virtual Exception* clone();
210  };
211 
213  class HERMES_API SolutionLoadFailureException : public Exception
214  {
215  public:
218  SolutionLoadFailureException(const char * msg, ...);
219  ~SolutionLoadFailureException() throw() {};
221  virtual Exception* clone();
222  };
223  }
224 }
225 #endif