Reference documentation for deal.II version 9.1.0-pre
exceptions.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_exceptions_h
17 #define dealii_exceptions_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <exception>
22 #include <ostream>
23 #include <string>
24 #include <type_traits>
25 
26 #ifdef DEAL_II_WITH_CUDA
27 # include <cusolverSp.h>
28 # include <cusparse.h>
29 #endif
30 
31 
32 DEAL_II_NAMESPACE_OPEN
33 
34 
49 class ExceptionBase : public std::exception
50 {
51 public:
55  ExceptionBase();
56 
61 
65  virtual ~ExceptionBase() noexcept override;
66 
72  operator=(const ExceptionBase &) = delete;
73 
79  void
80  set_fields(const char *file,
81  const int line,
82  const char *function,
83  const char *cond,
84  const char *exc_name);
85 
86 
90  virtual const char *
91  what() const noexcept override;
92 
96  const char *
97  get_exc_name() const;
98 
102  void
103  print_exc_data(std::ostream &out) const;
104 
109  virtual void
110  print_info(std::ostream &out) const;
111 
116  void
117  print_stack_trace(std::ostream &out) const;
118 
119 protected:
123  const char *file;
124 
128  unsigned int line;
129 
133  const char *function;
134 
138  const char *cond;
139 
143  const char *exc;
144 
149  mutable char **stacktrace;
150 
156 
157 #ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
158 
161  void *raw_stacktrace[25];
162 #endif
163 
164 private:
168  void
169  generate_message() const;
170 
175  mutable std::string what_str;
176 };
177 
178 #ifndef DOXYGEN
179 
186 # define DeclException0(Exception0) \
187  class Exception0 : public ::ExceptionBase \
188  {}
189 
190 
199 # define DeclExceptionMsg(Exception, defaulttext) \
200  class Exception : public ::ExceptionBase \
201  { \
202  public: \
203  Exception(const std::string &msg = defaulttext) \
204  : arg(msg) \
205  {} \
206  virtual ~Exception() noexcept \
207  {} \
208  virtual void \
209  print_info(std::ostream &out) const override \
210  { \
211  out << " " << arg << std::endl; \
212  } \
213  \
214  private: \
215  const std::string arg; \
216  }
217 
224 # define DeclException1(Exception1, type1, outsequence) \
225  class Exception1 : public ::ExceptionBase \
226  { \
227  public: \
228  Exception1(type1 const &a1) \
229  : arg1(a1) \
230  {} \
231  virtual ~Exception1() noexcept \
232  {} \
233  virtual void \
234  print_info(std::ostream &out) const override \
235  { \
236  out << " " outsequence << std::endl; \
237  } \
238  \
239  private: \
240  type1 const arg1; \
241  }
242 
243 
250 # define DeclException2(Exception2, type1, type2, outsequence) \
251  class Exception2 : public ::ExceptionBase \
252  { \
253  public: \
254  Exception2(type1 const &a1, type2 const &a2) \
255  : arg1(a1) \
256  , arg2(a2) \
257  {} \
258  virtual ~Exception2() noexcept \
259  {} \
260  virtual void \
261  print_info(std::ostream &out) const override \
262  { \
263  out << " " outsequence << std::endl; \
264  } \
265  \
266  private: \
267  type1 const arg1; \
268  type2 const arg2; \
269  }
270 
271 
278 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
279  class Exception3 : public ::ExceptionBase \
280  { \
281  public: \
282  Exception3(type1 const &a1, type2 const &a2, type3 const &a3) \
283  : arg1(a1) \
284  , arg2(a2) \
285  , arg3(a3) \
286  {} \
287  virtual ~Exception3() noexcept \
288  {} \
289  virtual void \
290  print_info(std::ostream &out) const override \
291  { \
292  out << " " outsequence << std::endl; \
293  } \
294  \
295  private: \
296  type1 const arg1; \
297  type2 const arg2; \
298  type3 const arg3; \
299  }
300 
301 
308 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
309  class Exception4 : public ::ExceptionBase \
310  { \
311  public: \
312  Exception4(type1 const &a1, \
313  type2 const &a2, \
314  type3 const &a3, \
315  type4 const &a4) \
316  : arg1(a1) \
317  , arg2(a2) \
318  , arg3(a3) \
319  , arg4(a4) \
320  {} \
321  virtual ~Exception4() noexcept \
322  {} \
323  virtual void \
324  print_info(std::ostream &out) const override \
325  { \
326  out << " " outsequence << std::endl; \
327  } \
328  \
329  private: \
330  type1 const arg1; \
331  type2 const arg2; \
332  type3 const arg3; \
333  type4 const arg4; \
334  }
335 
336 
343 # define DeclException5( \
344  Exception5, type1, type2, type3, type4, type5, outsequence) \
345  class Exception5 : public ::ExceptionBase \
346  { \
347  public: \
348  Exception5(type1 const &a1, \
349  type2 const &a2, \
350  type3 const &a3, \
351  type4 const &a4, \
352  type5 const &a5) \
353  : arg1(a1) \
354  , arg2(a2) \
355  , arg3(a3) \
356  , arg4(a4) \
357  , arg5(a5) \
358  {} \
359  virtual ~Exception5() noexcept \
360  {} \
361  virtual void \
362  print_info(std::ostream &out) const override \
363  { \
364  out << " " outsequence << std::endl; \
365  } \
366  \
367  private: \
368  type1 const arg1; \
369  type2 const arg2; \
370  type3 const arg3; \
371  type4 const arg4; \
372  type5 const arg5; \
373  }
374 
375 #else /*ifndef DOXYGEN*/
376 
377 // Dummy definitions for doxygen:
378 
385 # define DeclException0(Exception0) \
386  \
387  static ::ExceptionBase &Exception0()
388 
397 # define DeclExceptionMsg(Exception, defaulttext) \
398  \
399  \
400  static ::ExceptionBase &Exception()
401 
408 # define DeclException1(Exception1, type1, outsequence) \
409  \
410  \
411  static ::ExceptionBase &Exception1(type1 arg1)
412 
413 
420 # define DeclException2(Exception2, type1, type2, outsequence) \
421  \
422  \
423  static ::ExceptionBase &Exception2(type1 arg1, type2 arg2)
424 
425 
432 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
433  \
434  \
435  static ::ExceptionBase &Exception3(type1 arg1, type2 arg2, type3 arg3)
436 
437 
444 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
445  \
446  \
447  static ::ExceptionBase &Exception4(type1 arg1, \
448  type2 arg2, \
449  type3 arg3, \
450  type4 arg4)
451 
452 
459 # define DeclException5( \
460  Exception5, type1, type2, type3, type4, type5, outsequence) \
461  \
462  \
463  static ::ExceptionBase &Exception5( \
464  type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)
465 
466 #endif /*ifndef DOXYGEN*/
467 
468 
481 {
486 
491  "A piece of code is attempting a division by zero. This is "
492  "likely going to lead to results that make no sense.");
493 
506  std::complex<double>,
507  << "In a significant number of places, deal.II checks that some intermediate "
508  << "value is a finite number (as opposed to plus or minus infinity, or "
509  << "NaN/Not a Number). In the current function, we encountered a number "
510  << "that is not finite (its value is " << arg1 << " and therefore "
511  << "violates the current assertion).\n\n"
512  << "This may be due to the fact that some operation in this function "
513  << "created such a value, or because one of the arguments you passed "
514  << "to the function already had this value from some previous "
515  << "operation. In the latter case, this function only triggered the "
516  << "error but may not actually be responsible for the computation of "
517  << "the number that is not finite.\n\n"
518  << "There are two common cases where this situation happens. First, your "
519  << "code (or something in deal.II) divides by zero in a place where this "
520  << "should not happen. Or, you are trying to solve a linear system "
521  << "with an unsuitable solver (such as an indefinite or non-symmetric "
522  << "linear system using a Conjugate Gradient solver); such attempts "
523  << "oftentimes yield an operation somewhere that tries to divide "
524  << "by zero or take the square root of a negative value.\n\n"
525  << "In any case, when trying to find the source of the error, "
526  << "recall that the location where you are getting this error is "
527  << "simply the first place in the program where there is a check "
528  << "that a number (e.g., an element of a solution vector) is in fact "
529  << "finite, but that the actual error that computed the number "
530  << "may have happened far earlier. To find this location, you "
531  << "may want to add checks for finiteness in places of your "
532  << "program visited before the place where this error is produced."
533  << "One way to check for finiteness is to use the 'AssertIsFinite' "
534  << "macro.");
535 
540  "Your program tried to allocate some memory but this "
541  "allocation failed. Typically, this either means that "
542  "you simply do not have enough memory in your system, "
543  "or that you are (erroneously) trying to allocate "
544  "a chunk of memory that is simply beyond all reasonable "
545  "size, for example because the size of the object has "
546  "been computed incorrectly.");
547 
553  int,
554  << "Destroying memory handler while " << arg1
555  << " objects are still allocated.");
556 
561  "An input/output error has occurred. There are a number of "
562  "reasons why this may be happening, both for reading and "
563  "writing operations."
564  "\n\n"
565  "If this happens during an operation that tries to read "
566  "data: First, you may be "
567  "trying to read from a file that doesn't exist or that is "
568  "not readable given its file permissions. Second, deal.II "
569  "uses this error at times if it tries to "
570  "read information from a file but where the information "
571  "in the file does not correspond to the expected format. "
572  "An example would be a truncated file, or a mesh file "
573  "that contains not only sections that describe the "
574  "vertices and cells, but also sections for additional "
575  "data that deal.II does not understand."
576  "\n\n"
577  "If this happens during an operation that tries to write "
578  "data: you may be trying to write to a file to which file "
579  "or directory permissions do not allow you to write. A "
580  "typical example is where you specify an output file in "
581  "a directory that does not exist.");
582 
590  std::string,
591  << "Could not open file " << arg1 << ".");
592 
602  "You are trying to use functionality in deal.II that is "
603  "currently not implemented. In many cases, this indicates "
604  "that there simply didn't appear much of a need for it, or "
605  "that the author of the original code did not have the "
606  "time to implement a particular case. If you hit this "
607  "exception, it is therefore worth the time to look into "
608  "the code to find out whether you may be able to "
609  "implement the missing functionality. If you do, please "
610  "consider providing a patch to the deal.II development "
611  "sources (see the deal.II website on how to contribute).");
612 
634  "This exception -- which is used in many places in the "
635  "library -- usually indicates that some condition which "
636  "the author of the code thought must be satisfied at a "
637  "certain point in an algorithm, is not fulfilled. An "
638  "example would be that the first part of an algorithm "
639  "sorts elements of an array in ascending order, and "
640  "a second part of the algorithm later encounters an "
641  "element that is not larger than the previous one."
642  "\n\n"
643  "There is usually not very much you can do if you "
644  "encounter such an exception since it indicates an error "
645  "in deal.II, not in your own program. Try to come up with "
646  "the smallest possible program that still demonstrates "
647  "the error and contact the deal.II mailing lists with it "
648  "to obtain help.");
649 
658  "You (or a place in the library) are trying to call a "
659  "function that is declared as a virtual function in a "
660  "base class but that has not been overridden in your "
661  "derived class."
662  "\n\n"
663  "This exception happens in cases where the base class "
664  "cannot provide a useful default implementation for "
665  "the virtual function, but where we also do not want "
666  "to mark the function as abstract (i.e., with '=0' at the end) "
667  "because the function is not essential to the class in many "
668  "contexts. In cases like this, the base class provides "
669  "a dummy implementation that makes the compiler happy, but "
670  "that then throws the current exception."
671  "\n\n"
672  "A concrete example would be the 'Function' class. It declares "
673  "the existence of 'value()' and 'gradient()' member functions, "
674  "and both are marked as 'virtual'. Derived classes have to "
675  "override these functions for the values and gradients of a "
676  "particular function. On the other hand, not every function "
677  "has a gradient, and even for those that do, not every program "
678  "actually needs to evaluate it. Consequently, there is no "
679  "*requirement* that a derived class actually override the "
680  "'gradient()' function (as there would be had it been marked "
681  "as abstract). But, since the base class cannot know how to "
682  "compute the gradient, if a derived class does not override "
683  "the 'gradient()' function and it is called anyway, then the "
684  "default implementation in the base class will simply throw "
685  "an exception."
686  "\n\n"
687  "The exception you see is what happens in cases such as the "
688  "one just illustrated. To fix the problem, you need to "
689  "investigate whether the function being called should indeed have "
690  "been called; if the answer is 'yes', then you need to "
691  "implement the missing override in your class.");
692 
697 
702 
710  int,
711  << "You are trying to execute functionality that is "
712  << "impossible in " << arg1
713  << "d or simply does not make any sense.");
714 
723  int,
724  int,
725  << "You are trying to execute functionality that is "
726  << "impossible in dimensions <" << arg1 << "," << arg2
727  << "> or simply does not make any sense.");
728 
729 
734  "In a check in the code, deal.II encountered a zero in "
735  "a place where this does not make sense. See the condition "
736  "that was being checked and that is printed further up "
737  "in the error message to get more information on what "
738  "the erroneous zero corresponds to.");
739 
745  "The object you are trying to access is empty but it makes "
746  "no sense to attempt the operation you are trying on an "
747  "empty object.");
748 
757  std::size_t,
758  std::size_t,
759  << "Dimension " << arg1 << " not equal to " << arg2 << ".");
760 
766  int,
767  int,
768  int,
769  << "Dimension " << arg1 << " neither equal to " << arg2
770  << " nor to " << arg3 << ".");
771 
786  int,
787  int,
788  int,
789  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
790  << arg3 << ")."
791  << (arg2 == arg3 ?
792  " In the current case, this half-open range is in fact empty, "
793  "suggesting that you are accessing an element of an empty "
794  "collection such as a vector that has not been set to the "
795  "correct size." :
796  ""));
797 
813  template <typename T>
816  T,
817  T,
818  T,
819  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
820  << arg3 << ")."
821  << (arg2 == arg3 ?
822  " In the current case, this half-open range is in fact empty, "
823  "suggesting that you are accessing an element of an empty "
824  "collection such as a vector that has not been set to the "
825  "correct size." :
826  ""));
827 
832  int,
833  int,
834  << "Number " << arg1 << " must be larger than or equal "
835  << arg2 << ".");
836 
840  template <typename T>
842  T,
843  T,
844  << "Number " << arg1 << " must be larger than or equal "
845  << arg2 << ".");
846 
852  int,
853  int,
854  << "Division " << arg1 << " by " << arg2
855  << " has remainder different from zero.");
856 
866  "You are trying to use an iterator, but the iterator is "
867  "in an invalid state. This may indicate that the iterator "
868  "object has not been initialized, or that it has been "
869  "moved beyond the end of the range of valid elements.");
870 
876  "You are trying to use an iterator, but the iterator is "
877  "pointing past the end of the range of valid elements. "
878  "It is not valid to dereference the iterator in this "
879  "case.");
880 
894  DeclException1(ExcMessage, std::string, << arg1);
895 
900  "You are trying an operation on a vector that is only "
901  "allowed if the vector has no ghost elements, but the "
902  "vector you are operating on does have ghost elements. "
903  "Specifically, vectors with ghost elements are read-only "
904  "and cannot appear in operations that write into these "
905  "vectors."
906  "\n\n"
907  "See the glossary entry on 'Ghosted vectors' for more "
908  "information.");
909 
918  "You are trying an operation of the form 'vector=s' with "
919  "a nonzero scalar value 's'. However, such assignments "
920  "are only allowed if the right hand side is zero.");
921 
927  "You are attempting to use functionality that is only available "
928  "if deal.II was configured to use LAPACK, but cmake did not "
929  "find a valid LAPACK library.");
930 
936  "You are attempting to use functionality that is only available "
937  "if deal.II was configured to use NetCDF, but cmake did not "
938  "find a valid NetCDF library.");
939 
945  "You are attempting to use functionality that is only available "
946  "if deal.II was configured to use the function parser which "
947  "relies on the muparser library, but cmake did not "
948  "find a valid muparser library on your system and also did "
949  "not choose the one that comes bundled with deal.II.");
950 
956  "You are attempting to use functionality that is only available "
957  "if deal.II was configured to use Assimp, but cmake did not "
958  "find a valid Assimp library.");
959 
960 #ifdef DEAL_II_WITH_CUDA
961 
967  DeclException1(ExcCudaError, const char *, << arg1);
972  std::string,
973  << "There was an error in a cuSPARSE function: " << arg1);
974 #endif
975 
976 
977 #ifdef DEAL_II_WITH_MPI
978 
1000  class ExcMPI : public ::ExceptionBase
1001  {
1002  public:
1003  ExcMPI(const int error_code);
1004 
1005  virtual void
1006  print_info(std::ostream &out) const override;
1007 
1008  const int error_code;
1009  };
1010 #endif // DEAL_II_WITH_MPI
1011 } /*namespace StandardExceptions*/
1012 
1013 
1014 
1022 {
1041  void
1042  set_additional_assert_output(const char *const p);
1043 
1054  void
1056 
1070  void
1072 
1080  namespace internals
1081  {
1090  [[noreturn]] void
1091  abort(const ExceptionBase &exc);
1092 
1097  {
1114  };
1115 
1130  template <class ExceptionType>
1131  [[noreturn]] void
1133  const char * file,
1134  int line,
1135  const char * function,
1136  const char * cond,
1137  const char * exc_name,
1138  ExceptionType e) {
1139  // Fill the fields of the exception object
1140  e.set_fields(file, line, function, cond, exc_name);
1141 
1142  switch (handling)
1143  {
1144  case abort_on_exception:
1145  ::deal_II_exceptions::internals::abort(e);
1146  case throw_on_exception:
1147  throw e;
1148  // this function should never return (and AssertNothrow can);
1149  // something must have gone wrong in the error handling code for us
1150  // to get this far, so throw an exception.
1152  default:
1154  }
1155  }
1156 
1160  void do_issue_error_nothrow(const ExceptionBase &e) noexcept;
1161 
1170  template <class ExceptionType>
1171  void
1173  const char * file,
1174  int line,
1175  const char * function,
1176  const char * cond,
1177  const char * exc_name,
1178  ExceptionType e) noexcept
1179  {
1180  static_assert(std::is_base_of<ExceptionBase, ExceptionType>::value,
1181  "The provided exception must inherit from ExceptionBase.");
1182  // Fill the fields of the exception object
1183  e.set_fields(file, line, function, cond, exc_name);
1184  // avoid moving a bunch of code into the header by dispatching to
1185  // another function:
1187  }
1188 #ifdef DEAL_II_WITH_CUDA
1189 
1194  std::string
1195  get_cusparse_error_string(const cusparseStatus_t error_code);
1196 
1202  std::string
1203  get_cusolver_error_string(const cusolverStatus_t error_code);
1204 #endif
1205  } /*namespace internals*/
1206 
1207 } /*namespace deal_II_exceptions*/
1208 
1209 
1210 
1225 #ifdef DEBUG
1226 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1227 # define Assert(cond, exc) \
1228  { \
1229  if (__builtin_expect(!(cond), false)) \
1230  ::deal_II_exceptions::internals::issue_error_noreturn( \
1231  ::deal_II_exceptions::internals::abort_on_exception, \
1232  __FILE__, \
1233  __LINE__, \
1234  __PRETTY_FUNCTION__, \
1235  #cond, \
1236  #exc, \
1237  exc); \
1238  }
1239 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1240 # define Assert(cond, exc) \
1241  { \
1242  if (!(cond)) \
1243  ::deal_II_exceptions::internals::issue_error_noreturn( \
1244  ::deal_II_exceptions::internals::abort_on_exception, \
1245  __FILE__, \
1246  __LINE__, \
1247  __PRETTY_FUNCTION__, \
1248  #cond, \
1249  #exc, \
1250  exc); \
1251  }
1252 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1253 #else
1254 # define Assert(cond, exc) \
1255  {}
1256 #endif
1257 
1258 
1259 
1276 #ifdef DEBUG
1277 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1278 # define AssertNothrow(cond, exc) \
1279  { \
1280  if (__builtin_expect(!(cond), false)) \
1281  ::deal_II_exceptions::internals::issue_error_nothrow( \
1282  ::deal_II_exceptions::internals:: \
1283  abort_nothrow_on_exception, \
1284  __FILE__, \
1285  __LINE__, \
1286  __PRETTY_FUNCTION__, \
1287  #cond, \
1288  #exc, \
1289  exc); \
1290  }
1291 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1292 # define AssertNothrow(cond, exc) \
1293  { \
1294  if (!(cond)) \
1295  ::deal_II_exceptions::internals::issue_error_nothrow( \
1296  ::deal_II_exceptions::internals:: \
1297  abort_nothrow_on_exception, \
1298  __FILE__, \
1299  __LINE__, \
1300  __PRETTY_FUNCTION__, \
1301  #cond, \
1302  #exc, \
1303  exc); \
1304  }
1305 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1306 #else
1307 # define AssertNothrow(cond, exc) \
1308  {}
1309 #endif
1310 
1328 #ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1329 # define AssertThrow(cond, exc) \
1330  { \
1331  if (__builtin_expect(!(cond), false)) \
1332  ::deal_II_exceptions::internals::issue_error_noreturn( \
1333  ::deal_II_exceptions::internals::throw_on_exception, \
1334  __FILE__, \
1335  __LINE__, \
1336  __PRETTY_FUNCTION__, \
1337  #cond, \
1338  #exc, \
1339  exc); \
1340  }
1341 #else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1342 # define AssertThrow(cond, exc) \
1343  { \
1344  if (!(cond)) \
1345  ::deal_II_exceptions::internals::issue_error_noreturn( \
1346  ::deal_II_exceptions::internals::throw_on_exception, \
1347  __FILE__, \
1348  __LINE__, \
1349  __PRETTY_FUNCTION__, \
1350  #cond, \
1351  #exc, \
1352  exc); \
1353  }
1354 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1355 
1366 #define AssertDimension(dim1, dim2) \
1367  Assert((dim1) == (dim2), ::ExcDimensionMismatch((dim1), (dim2)))
1368 
1369 
1377 #define AssertVectorVectorDimension(vec, dim1, dim2) \
1378  AssertDimension((vec).size(), (dim1)); \
1379  for (unsigned int i = 0; i < dim1; ++i) \
1380  { \
1381  AssertDimension((vec)[i].size(), (dim2)); \
1382  }
1383 
1384 namespace internal
1385 {
1386  // Workaround to allow for commas in template parameter lists
1387  // in preprocessor macros as found in
1388  // https://stackoverflow.com/questions/13842468/comma-in-c-c-macro
1389  template <typename T>
1390  struct argument_type;
1391  template <typename T, typename U>
1392  struct argument_type<T(U)>
1393  {
1394  using type = U;
1395  };
1396 } // namespace internal
1397 
1407 #define AssertIndexRange(index, range) \
1408  Assert( \
1409  static_cast<typename ::internal::argument_type<void( \
1410  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1411  type>(index) < \
1412  static_cast<typename ::internal::argument_type<void( \
1413  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1414  type>(range), \
1415  ExcIndexRangeType<typename ::internal::argument_type<void( \
1416  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1417  type>((index), 0, (range)))
1418 
1428 #define AssertIsFinite(number) \
1429  Assert(::numbers::is_finite(number), \
1430  ::ExcNumberNotFinite(std::complex<double>(number)))
1431 
1432 #ifdef DEAL_II_WITH_MPI
1433 
1443 # define AssertThrowMPI(error_code) \
1444  AssertThrow(error_code == MPI_SUCCESS, ::ExcMPI(error_code))
1445 #else
1446 # define AssertThrowMPI(error_code) \
1447  {}
1448 #endif // DEAL_II_WITH_MPI
1449 
1450 #ifdef DEAL_II_WITH_CUDA
1451 
1458 # ifdef DEBUG
1459 # define AssertCuda(error_code) \
1460  Assert(error_code == cudaSuccess, \
1461  ::ExcCudaError(cudaGetErrorString(error_code)))
1462 # else
1463 # define AssertCuda(error_code) \
1464  { \
1465  (void)(error_code); \
1466  }
1467 # endif
1468 
1476 # ifdef DEBUG
1477 # define AssertCusparse(error_code) \
1478  Assert( \
1479  error_code == CUSPARSE_STATUS_SUCCESS, \
1480  ExcCusparseError( \
1481  deal_II_exceptions::internals::get_cusparse_error_string( \
1482  error_code)))
1483 # else
1484 # define AssertCusparse(error_code) \
1485  { \
1486  (void)(error_code); \
1487  }
1488 # endif
1489 
1490 # ifdef DEBUG
1491 # define AssertCusolver(error_code) \
1492  Assert( \
1493  error_code == CUSOLVER_STATUS_SUCCESS, \
1494  ExcCusparseError( \
1495  deal_II_exceptions::internals::get_cusolver_error_string( \
1496  error_code)))
1497 # else
1498 # define AssertCusolver(error_code) \
1499  { \
1500  (void)(error_code); \
1501  }
1502 # endif
1503 
1504 #endif
1505 
1506 using namespace StandardExceptions;
1507 
1508 DEAL_II_NAMESPACE_CLOSE
1509 
1510 #endif
static::ExceptionBase & ExcCudaError(const char *arg1)
static::ExceptionBase & ExcPureFunctionCalled()
static::ExceptionBase & ExcNeedsFunctionparser()
void print_exc_data(std::ostream &out) const
Definition: exceptions.cc:177
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:420
static::ExceptionBase & ExcImpossibleInDimSpacedim(int arg1, int arg2)
void suppress_stacktrace_in_exceptions()
Definition: exceptions.cc:55
static::ExceptionBase & ExcIO()
static::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
static::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
std::string get_cusolver_error_string(const cusolverStatus_t error_code)
Definition: exceptions.cc:527
void set_additional_assert_output(const char *const p)
Definition: exceptions.cc:47
static::ExceptionBase & ExcNotInitialized()
static::ExceptionBase & ExcOutOfMemory()
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static::ExceptionBase & ExcDivideByZero()
void * raw_stacktrace[25]
Definition: exceptions.h:161
static::ExceptionBase & ExcInvalidIterator()
static::ExceptionBase & ExcNeedsLAPACK()
ExceptionBase operator=(const ExceptionBase &)=delete
static::ExceptionBase & ExcInvalidState()
static::ExceptionBase & ExcMessage(std::string arg1)
static::ExceptionBase & ExcImpossibleInDim(int arg1)
static::ExceptionBase & ExcNeedsNetCDF()
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
static::ExceptionBase & ExcMemoryLeak(int arg1)
void set_fields(const char *file, const int line, const char *function, const char *cond, const char *exc_name)
Definition: exceptions.cc:123
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void generate_message() const
Definition: exceptions.cc:306
virtual void print_info(std::ostream &out) const
Definition: exceptions.cc:209
void do_issue_error_nothrow(const ExceptionBase &e) noexcept
Definition: exceptions.cc:452
std::string get_cusparse_error_string(const cusparseStatus_t error_code)
Definition: exceptions.cc:481
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:397
#define DeclException0(Exception0)
Definition: exceptions.h:385
static::ExceptionBase & ExcNeedsAssimp()
virtual ~ExceptionBase() noexceptoverride
Definition: exceptions.cc:114
virtual const char * what() const noexceptoverride
Definition: exceptions.cc:146
static::ExceptionBase & ExcIndexRangeType(T arg1, T arg2, T arg3)
std::string what_str
Definition: exceptions.h:175
unsigned int line
Definition: exceptions.h:128
void print_stack_trace(std::ostream &out) const
Definition: exceptions.cc:217
static::ExceptionBase & ExcLowerRange(int arg1, int arg2)
void issue_error_nothrow(ExceptionHandling, const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e) noexcept
Definition: exceptions.h:1172
static::ExceptionBase & ExcGhostsPresent()
static::ExceptionBase & ExcIteratorPastEnd()
const char * exc
Definition: exceptions.h:143
const char * cond
Definition: exceptions.h:138
static::ExceptionBase & ExcNumberNotFinite(std::complex< double > arg1)
void issue_error_noreturn(ExceptionHandling handling, const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e)
Definition: exceptions.h:1132
const char * file
Definition: exceptions.h:123
void abort(const ExceptionBase &exc)
Definition: exceptions.cc:468
static::ExceptionBase & ExcCusparseError(std::string arg1)
static::ExceptionBase & ExcEmptyObject()
static::ExceptionBase & ExcNotMultiple(int arg1, int arg2)
static::ExceptionBase & ExcNotImplemented()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:432
const char * get_exc_name() const
Definition: exceptions.cc:169
char ** stacktrace
Definition: exceptions.h:149
void disable_abort_on_exception()
Definition: exceptions.cc:63
static::ExceptionBase & ExcZero()
static::ExceptionBase & ExcFileNotOpen(std::string arg1)
int n_stacktrace_frames
Definition: exceptions.h:155
static::ExceptionBase & ExcLowerRangeType(T arg1, T arg2)
static::ExceptionBase & ExcInternalError()