Reference documentation for deal.II version Git c679197b1a 2019-11-19 16:09:58 -0500
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
exceptions.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2019 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 
197 # define DeclException0(Exception0) \
198  class Exception0 : public ::ExceptionBase \
199  {}
200 
201 
221 # define DeclExceptionMsg(Exception, defaulttext) \
222  class Exception : public ::ExceptionBase \
223  { \
224  public: \
225  Exception(const std::string &msg = defaulttext) \
226  : arg(msg) \
227  {} \
228  virtual ~Exception() noexcept \
229  {} \
230  virtual void \
231  print_info(std::ostream &out) const override \
232  { \
233  out << " " << arg << std::endl; \
234  } \
235  \
236  private: \
237  const std::string arg; \
238  }
239 
257 # define DeclException1(Exception1, type1, outsequence) \
258  class Exception1 : public ::ExceptionBase \
259  { \
260  public: \
261  Exception1(type1 const &a1) \
262  : arg1(a1) \
263  {} \
264  virtual ~Exception1() noexcept \
265  {} \
266  virtual void \
267  print_info(std::ostream &out) const override \
268  { \
269  out << " " outsequence << std::endl; \
270  } \
271  \
272  private: \
273  type1 const arg1; \
274  }
275 
276 
294 # define DeclException2(Exception2, type1, type2, outsequence) \
295  class Exception2 : public ::ExceptionBase \
296  { \
297  public: \
298  Exception2(type1 const &a1, type2 const &a2) \
299  : arg1(a1) \
300  , arg2(a2) \
301  {} \
302  virtual ~Exception2() noexcept \
303  {} \
304  virtual void \
305  print_info(std::ostream &out) const override \
306  { \
307  out << " " outsequence << std::endl; \
308  } \
309  \
310  private: \
311  type1 const arg1; \
312  type2 const arg2; \
313  }
314 
315 
333 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
334  class Exception3 : public ::ExceptionBase \
335  { \
336  public: \
337  Exception3(type1 const &a1, type2 const &a2, type3 const &a3) \
338  : arg1(a1) \
339  , arg2(a2) \
340  , arg3(a3) \
341  {} \
342  virtual ~Exception3() noexcept \
343  {} \
344  virtual void \
345  print_info(std::ostream &out) const override \
346  { \
347  out << " " outsequence << std::endl; \
348  } \
349  \
350  private: \
351  type1 const arg1; \
352  type2 const arg2; \
353  type3 const arg3; \
354  }
355 
356 
374 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
375  class Exception4 : public ::ExceptionBase \
376  { \
377  public: \
378  Exception4(type1 const &a1, \
379  type2 const &a2, \
380  type3 const &a3, \
381  type4 const &a4) \
382  : arg1(a1) \
383  , arg2(a2) \
384  , arg3(a3) \
385  , arg4(a4) \
386  {} \
387  virtual ~Exception4() noexcept \
388  {} \
389  virtual void \
390  print_info(std::ostream &out) const override \
391  { \
392  out << " " outsequence << std::endl; \
393  } \
394  \
395  private: \
396  type1 const arg1; \
397  type2 const arg2; \
398  type3 const arg3; \
399  type4 const arg4; \
400  }
401 
402 
420 # define DeclException5( \
421  Exception5, type1, type2, type3, type4, type5, outsequence) \
422  class Exception5 : public ::ExceptionBase \
423  { \
424  public: \
425  Exception5(type1 const &a1, \
426  type2 const &a2, \
427  type3 const &a3, \
428  type4 const &a4, \
429  type5 const &a5) \
430  : arg1(a1) \
431  , arg2(a2) \
432  , arg3(a3) \
433  , arg4(a4) \
434  , arg5(a5) \
435  {} \
436  virtual ~Exception5() noexcept \
437  {} \
438  virtual void \
439  print_info(std::ostream &out) const override \
440  { \
441  out << " " outsequence << std::endl; \
442  } \
443  \
444  private: \
445  type1 const arg1; \
446  type2 const arg2; \
447  type3 const arg3; \
448  type4 const arg4; \
449  type5 const arg5; \
450  }
451 
452 #else /*ifndef DOXYGEN*/
453 
454 // Dummy definitions for doxygen:
455 
473 # define DeclException0(Exception0) \
474  \
475  static ::ExceptionBase &Exception0()
476 
496 # define DeclExceptionMsg(Exception, defaulttext) \
497  \
498  \
499  static ::ExceptionBase &Exception()
500 
518 # define DeclException1(Exception1, type1, outsequence) \
519  \
520  \
521  static ::ExceptionBase &Exception1(type1 arg1)
522 
523 
541 # define DeclException2(Exception2, type1, type2, outsequence) \
542  \
543  \
544  static ::ExceptionBase &Exception2(type1 arg1, type2 arg2)
545 
546 
564 # define DeclException3(Exception3, type1, type2, type3, outsequence) \
565  \
566  \
567  static ::ExceptionBase &Exception3(type1 arg1, type2 arg2, type3 arg3)
568 
569 
587 # define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
588  \
589  \
590  static ::ExceptionBase &Exception4(type1 arg1, \
591  type2 arg2, \
592  type3 arg3, \
593  type4 arg4)
594 
595 
613 # define DeclException5( \
614  Exception5, type1, type2, type3, type4, type5, outsequence) \
615  \
616  \
617  static ::ExceptionBase &Exception5( \
618  type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)
619 
620 #endif /*ifndef DOXYGEN*/
621 
622 
635 {
640 
645  "A piece of code is attempting a division by zero. This is "
646  "likely going to lead to results that make no sense.");
647 
660  std::complex<double>,
661  << "In a significant number of places, deal.II checks that some intermediate "
662  << "value is a finite number (as opposed to plus or minus infinity, or "
663  << "NaN/Not a Number). In the current function, we encountered a number "
664  << "that is not finite (its value is " << arg1 << " and therefore "
665  << "violates the current assertion).\n\n"
666  << "This may be due to the fact that some operation in this function "
667  << "created such a value, or because one of the arguments you passed "
668  << "to the function already had this value from some previous "
669  << "operation. In the latter case, this function only triggered the "
670  << "error but may not actually be responsible for the computation of "
671  << "the number that is not finite.\n\n"
672  << "There are two common cases where this situation happens. First, your "
673  << "code (or something in deal.II) divides by zero in a place where this "
674  << "should not happen. Or, you are trying to solve a linear system "
675  << "with an unsuitable solver (such as an indefinite or non-symmetric "
676  << "linear system using a Conjugate Gradient solver); such attempts "
677  << "oftentimes yield an operation somewhere that tries to divide "
678  << "by zero or take the square root of a negative value.\n\n"
679  << "In any case, when trying to find the source of the error, "
680  << "recall that the location where you are getting this error is "
681  << "simply the first place in the program where there is a check "
682  << "that a number (e.g., an element of a solution vector) is in fact "
683  << "finite, but that the actual error that computed the number "
684  << "may have happened far earlier. To find this location, you "
685  << "may want to add checks for finiteness in places of your "
686  << "program visited before the place where this error is produced. "
687  << "One way to check for finiteness is to use the 'AssertIsFinite' "
688  << "macro.");
689 
694  std::size_t,
695  "Your program tried to allocate some memory but this "
696  "allocation failed. Typically, this either means that "
697  "you simply do not have enough memory in your system, "
698  "or that you are (erroneously) trying to allocate "
699  "a chunk of memory that is simply beyond all reasonable "
700  "size, for example because the size of the object has "
701  "been computed incorrectly."
702  "\n\n"
703  "In the current case, the request was for "
704  << arg1 << " bytes.");
705 
711  int,
712  << "Destroying memory handler while " << arg1
713  << " objects are still allocated.");
714 
719  "An input/output error has occurred. There are a number of "
720  "reasons why this may be happening, both for reading and "
721  "writing operations."
722  "\n\n"
723  "If this happens during an operation that tries to read "
724  "data: First, you may be "
725  "trying to read from a file that doesn't exist or that is "
726  "not readable given its file permissions. Second, deal.II "
727  "uses this error at times if it tries to "
728  "read information from a file but where the information "
729  "in the file does not correspond to the expected format. "
730  "An example would be a truncated file, or a mesh file "
731  "that contains not only sections that describe the "
732  "vertices and cells, but also sections for additional "
733  "data that deal.II does not understand."
734  "\n\n"
735  "If this happens during an operation that tries to write "
736  "data: you may be trying to write to a file to which file "
737  "or directory permissions do not allow you to write. A "
738  "typical example is where you specify an output file in "
739  "a directory that does not exist.");
740 
748  std::string,
749  << "Could not open file " << arg1 << ".");
750 
760  "You are trying to use functionality in deal.II that is "
761  "currently not implemented. In many cases, this indicates "
762  "that there simply didn't appear much of a need for it, or "
763  "that the author of the original code did not have the "
764  "time to implement a particular case. If you hit this "
765  "exception, it is therefore worth the time to look into "
766  "the code to find out whether you may be able to "
767  "implement the missing functionality. If you do, please "
768  "consider providing a patch to the deal.II development "
769  "sources (see the deal.II website on how to contribute).");
770 
792  "This exception -- which is used in many places in the "
793  "library -- usually indicates that some condition which "
794  "the author of the code thought must be satisfied at a "
795  "certain point in an algorithm, is not fulfilled. An "
796  "example would be that the first part of an algorithm "
797  "sorts elements of an array in ascending order, and "
798  "a second part of the algorithm later encounters an "
799  "element that is not larger than the previous one."
800  "\n\n"
801  "There is usually not very much you can do if you "
802  "encounter such an exception since it indicates an error "
803  "in deal.II, not in your own program. Try to come up with "
804  "the smallest possible program that still demonstrates "
805  "the error and contact the deal.II mailing lists with it "
806  "to obtain help.");
807 
816  "You (or a place in the library) are trying to call a "
817  "function that is declared as a virtual function in a "
818  "base class but that has not been overridden in your "
819  "derived class."
820  "\n\n"
821  "This exception happens in cases where the base class "
822  "cannot provide a useful default implementation for "
823  "the virtual function, but where we also do not want "
824  "to mark the function as abstract (i.e., with '=0' at the end) "
825  "because the function is not essential to the class in many "
826  "contexts. In cases like this, the base class provides "
827  "a dummy implementation that makes the compiler happy, but "
828  "that then throws the current exception."
829  "\n\n"
830  "A concrete example would be the 'Function' class. It declares "
831  "the existence of 'value()' and 'gradient()' member functions, "
832  "and both are marked as 'virtual'. Derived classes have to "
833  "override these functions for the values and gradients of a "
834  "particular function. On the other hand, not every function "
835  "has a gradient, and even for those that do, not every program "
836  "actually needs to evaluate it. Consequently, there is no "
837  "*requirement* that a derived class actually override the "
838  "'gradient()' function (as there would be had it been marked "
839  "as abstract). But, since the base class cannot know how to "
840  "compute the gradient, if a derived class does not override "
841  "the 'gradient()' function and it is called anyway, then the "
842  "default implementation in the base class will simply throw "
843  "an exception."
844  "\n\n"
845  "The exception you see is what happens in cases such as the "
846  "one just illustrated. To fix the problem, you need to "
847  "investigate whether the function being called should indeed have "
848  "been called; if the answer is 'yes', then you need to "
849  "implement the missing override in your class.");
850 
855 
860 
868  int,
869  << "You are trying to execute functionality that is "
870  << "impossible in " << arg1
871  << "d or simply does not make any sense.");
872 
881  int,
882  int,
883  << "You are trying to execute functionality that is "
884  << "impossible in dimensions <" << arg1 << "," << arg2
885  << "> or simply does not make any sense.");
886 
887 
892  "In a check in the code, deal.II encountered a zero in "
893  "a place where this does not make sense. See the condition "
894  "that was being checked and that is printed further up "
895  "in the error message to get more information on what "
896  "the erroneous zero corresponds to.");
897 
903  "The object you are trying to access is empty but it makes "
904  "no sense to attempt the operation you are trying on an "
905  "empty object.");
906 
915  std::size_t,
916  std::size_t,
917  << "Dimension " << arg1 << " not equal to " << arg2 << ".");
918 
924  int,
925  int,
926  int,
927  << "Dimension " << arg1 << " neither equal to " << arg2
928  << " nor to " << arg3 << ".");
929 
944  int,
945  int,
946  int,
947  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
948  << arg3 << ")."
949  << (arg2 == arg3 ?
950  " In the current case, this half-open range is in fact empty, "
951  "suggesting that you are accessing an element of an empty "
952  "collection such as a vector that has not been set to the "
953  "correct size." :
954  ""));
955 
971  template <typename T>
974  T,
975  T,
976  T,
977  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
978  << arg3 << ")."
979  << (arg2 == arg3 ?
980  " In the current case, this half-open range is in fact empty, "
981  "suggesting that you are accessing an element of an empty "
982  "collection such as a vector that has not been set to the "
983  "correct size." :
984  ""));
985 
990  int,
991  int,
992  << "Number " << arg1 << " must be larger than or equal "
993  << arg2 << ".");
994 
998  template <typename T>
1000  T,
1001  T,
1002  << "Number " << arg1 << " must be larger than or equal "
1003  << arg2 << ".");
1004 
1010  int,
1011  int,
1012  << "Division " << arg1 << " by " << arg2
1013  << " has remainder different from zero.");
1014 
1024  "You are trying to use an iterator, but the iterator is "
1025  "in an invalid state. This may indicate that the iterator "
1026  "object has not been initialized, or that it has been "
1027  "moved beyond the end of the range of valid elements.");
1028 
1034  "You are trying to use an iterator, but the iterator is "
1035  "pointing past the end of the range of valid elements. "
1036  "It is not valid to dereference the iterator in this "
1037  "case.");
1038 
1052  DeclException1(ExcMessage, std::string, << arg1);
1053 
1058  "You are trying an operation on a vector that is only "
1059  "allowed if the vector has no ghost elements, but the "
1060  "vector you are operating on does have ghost elements. "
1061  "Specifically, vectors with ghost elements are read-only "
1062  "and cannot appear in operations that write into these "
1063  "vectors."
1064  "\n\n"
1065  "See the glossary entry on 'Ghosted vectors' for more "
1066  "information.");
1067 
1076  "You are trying an operation of the form 'vector=s' with "
1077  "a nonzero scalar value 's'. However, such assignments "
1078  "are only allowed if the right hand side is zero.");
1079 
1085  "You are attempting to use functionality that is only available "
1086  "if deal.II was configured to use LAPACK, but cmake did not "
1087  "find a valid LAPACK library.");
1088 
1096  "You are attempting to use functionality that is only available "
1097  "if deal.II was configured to use NetCDF, but cmake did not "
1098  "find a valid NetCDF library.");
1099 
1105  "You are attempting to use functionality that is only available "
1106  "if deal.II was configured to use the function parser which "
1107  "relies on the muparser library, but cmake did not "
1108  "find a valid muparser library on your system and also did "
1109  "not choose the one that comes bundled with deal.II.");
1110 
1116  "You are attempting to use functionality that is only available "
1117  "if deal.II was configured to use Assimp, but cmake did not "
1118  "find a valid Assimp library.");
1119 
1120 #ifdef DEAL_II_WITH_CUDA
1121 
1127  DeclException1(ExcCudaError, const char *, << arg1);
1132  std::string,
1133  << "There was an error in a cuSPARSE function: " << arg1);
1134 #endif
1135 
1136 
1137 #ifdef DEAL_II_WITH_MPI
1138 
1160  class ExcMPI : public ::ExceptionBase
1161  {
1162  public:
1163  ExcMPI(const int error_code);
1164 
1165  virtual void
1166  print_info(std::ostream &out) const override;
1167 
1168  const int error_code;
1169  };
1170 #endif // DEAL_II_WITH_MPI
1171 } /*namespace StandardExceptions*/
1172 
1173 
1174 
1182 {
1183  namespace internals
1184  {
1192  extern bool allow_abort_on_exception;
1193  } // namespace internals
1194 
1213  void
1214  set_additional_assert_output(const char *const p);
1215 
1226  void
1228 
1242  void
1244 
1252  namespace internals
1253  {
1258  [[noreturn]] void
1259  abort(const ExceptionBase &exc) noexcept;
1260 
1265  {
1276  };
1277 
1295  template <class ExceptionType>
1296  [[noreturn]] void
1298  const char * file,
1299  int line,
1300  const char * function,
1301  const char * cond,
1302  const char * exc_name,
1303  ExceptionType e) {
1304  // Fill the fields of the exception object
1305  e.set_fields(file, line, function, cond, exc_name);
1306 
1307  switch (handling)
1308  {
1310  {
1313  internals::abort(e);
1314  else
1315  {
1316  // We are not allowed to abort, so just throw the error:
1317  throw e;
1318  }
1319  }
1320  case throw_on_exception:
1321  throw e;
1322  // this function should never return (and AssertNothrow can);
1323  // something must have gone wrong in the error handling code for us
1324  // to get this far, so throw an exception.
1325  default:
1327  }
1328  }
1329 
1333  void do_issue_error_nothrow(const ExceptionBase &e) noexcept;
1334 
1343  template <class ExceptionType>
1344  void
1346  int line,
1347  const char * function,
1348  const char * cond,
1349  const char * exc_name,
1350  ExceptionType e) noexcept
1351  {
1352  static_assert(std::is_base_of<ExceptionBase, ExceptionType>::value,
1353  "The provided exception must inherit from ExceptionBase.");
1354  // Fill the fields of the exception object
1355  e.set_fields(file, line, function, cond, exc_name);
1356  // avoid moving a bunch of code into the header by dispatching to
1357  // another function:
1359  }
1360 #ifdef DEAL_II_WITH_CUDA
1361 
1366  std::string
1367  get_cusparse_error_string(const cusparseStatus_t error_code);
1368 
1374  std::string
1375  get_cusolver_error_string(const cusolverStatus_t error_code);
1376 #endif
1377  } /*namespace internals*/
1378 
1379 } /*namespace deal_II_exceptions*/
1380 
1381 
1382 
1409 #ifdef DEBUG
1410 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1411 # define Assert(cond, exc) \
1412  { \
1413  if (__builtin_expect(!(cond), false)) \
1414  ::deal_II_exceptions::internals::issue_error_noreturn( \
1415  ::deal_II_exceptions::internals:: \
1416  abort_or_throw_on_exception, \
1417  __FILE__, \
1418  __LINE__, \
1419  __PRETTY_FUNCTION__, \
1420  #cond, \
1421  #exc, \
1422  exc); \
1423  }
1424 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1425 # define Assert(cond, exc) \
1426  { \
1427  if (!(cond)) \
1428  ::deal_II_exceptions::internals::issue_error_noreturn( \
1429  ::deal_II_exceptions::internals:: \
1430  abort_or_throw_on_exception, \
1431  __FILE__, \
1432  __LINE__, \
1433  __PRETTY_FUNCTION__, \
1434  #cond, \
1435  #exc, \
1436  exc); \
1437  }
1438 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1439 #else
1440 # define Assert(cond, exc) \
1441  {}
1442 #endif
1443 
1444 
1445 
1473 #ifdef DEBUG
1474 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1475 # define AssertNothrow(cond, exc) \
1476  { \
1477  if (__builtin_expect(!(cond), false)) \
1478  ::deal_II_exceptions::internals::issue_error_nothrow( \
1479  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1480  }
1481 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1482 # define AssertNothrow(cond, exc) \
1483  { \
1484  if (!(cond)) \
1485  ::deal_II_exceptions::internals::issue_error_nothrow( \
1486  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1487  }
1488 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1489 #else
1490 # define AssertNothrow(cond, exc) \
1491  {}
1492 #endif
1493 
1522 #ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1523 # define AssertThrow(cond, exc) \
1524  { \
1525  if (__builtin_expect(!(cond), false)) \
1526  ::deal_II_exceptions::internals::issue_error_noreturn( \
1527  ::deal_II_exceptions::internals::throw_on_exception, \
1528  __FILE__, \
1529  __LINE__, \
1530  __PRETTY_FUNCTION__, \
1531  #cond, \
1532  #exc, \
1533  exc); \
1534  }
1535 #else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1536 # define AssertThrow(cond, exc) \
1537  { \
1538  if (!(cond)) \
1539  ::deal_II_exceptions::internals::issue_error_noreturn( \
1540  ::deal_II_exceptions::internals::throw_on_exception, \
1541  __FILE__, \
1542  __LINE__, \
1543  __PRETTY_FUNCTION__, \
1544  #cond, \
1545  #exc, \
1546  exc); \
1547  }
1548 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1549 
1571 #define AssertDimension(dim1, dim2) \
1572  Assert(static_cast<typename ::internal::argument_type<void( \
1573  typename std::common_type<decltype(dim1), \
1574  decltype(dim2)>::type)>::type>(dim1) == \
1575  static_cast<typename ::internal::argument_type<void( \
1576  typename std::common_type<decltype(dim1), \
1577  decltype(dim2)>::type)>::type>(dim2), \
1578  ::ExcDimensionMismatch((dim1), (dim2)))
1579 
1580 
1599 #define AssertVectorVectorDimension(VEC, DIM1, DIM2) \
1600  AssertDimension(VEC.size(), DIM1); \
1601  for (const auto &subvector : VEC) \
1602  { \
1603  (void)subvector; \
1604  AssertDimension(subvector.size(), DIM2); \
1605  }
1606 
1607 namespace internal
1608 {
1609  // Workaround to allow for commas in template parameter lists
1610  // in preprocessor macros as found in
1611  // https://stackoverflow.com/questions/13842468/comma-in-c-c-macro
1612  template <typename T>
1613  struct argument_type;
1614  template <typename T, typename U>
1615  struct argument_type<T(U)>
1616  {
1617  using type = U;
1618  };
1619 } // namespace internal
1620 
1641 #define AssertIndexRange(index, range) \
1642  Assert( \
1643  static_cast<typename ::internal::argument_type<void( \
1644  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1645  type>(index) < \
1646  static_cast<typename ::internal::argument_type<void( \
1647  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1648  type>(range), \
1649  ExcIndexRangeType<typename ::internal::argument_type<void( \
1650  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1651  type>((index), 0, (range)))
1652 
1673 #define AssertIsFinite(number) \
1674  Assert(::numbers::is_finite(number), \
1675  ::ExcNumberNotFinite(std::complex<double>(number)))
1676 
1677 #ifdef DEAL_II_WITH_MPI
1678 
1699 # define AssertThrowMPI(error_code) \
1700  AssertThrow(error_code == MPI_SUCCESS, ::ExcMPI(error_code))
1701 #else
1702 # define AssertThrowMPI(error_code) \
1703  {}
1704 #endif // DEAL_II_WITH_MPI
1705 
1706 #ifdef DEAL_II_WITH_CUDA
1707 
1725 # ifdef DEBUG
1726 # define AssertCuda(error_code) \
1727  Assert(error_code == cudaSuccess, \
1728  ::ExcCudaError(cudaGetErrorString(error_code)))
1729 # else
1730 # define AssertCuda(error_code) \
1731  { \
1732  (void)(error_code); \
1733  }
1734 # endif
1735 
1753 # ifdef DEBUG
1754 # define AssertNothrowCuda(error_code) \
1755  AssertNothrow(error_code == cudaSuccess, \
1756  ::ExcCudaError(cudaGetErrorString(error_code)))
1757 # else
1758 # define AssertNothrowCuda(error_code) \
1759  { \
1760  (void)(error_code); \
1761  }
1762 # endif
1763 
1782 # ifdef DEBUG
1783 # define AssertCusparse(error_code) \
1784  Assert( \
1785  error_code == CUSPARSE_STATUS_SUCCESS, \
1786  ExcCusparseError( \
1787  deal_II_exceptions::internals::get_cusparse_error_string( \
1788  error_code)))
1789 # else
1790 # define AssertCusparse(error_code) \
1791  { \
1792  (void)(error_code); \
1793  }
1794 # endif
1795 
1813 # ifdef DEBUG
1814 # define AssertNothrowCusparse(error_code) \
1815  AssertNothrow( \
1816  error_code == CUSPARSE_STATUS_SUCCESS, \
1817  ExcCusparseError( \
1818  deal_II_exceptions::internals::get_cusparse_error_string( \
1819  error_code)))
1820 # else
1821 # define AssertNothrowCusparse(error_code) \
1822  { \
1823  (void)(error_code); \
1824  }
1825 # endif
1826 
1845 # ifdef DEBUG
1846 # define AssertCusolver(error_code) \
1847  Assert( \
1848  error_code == CUSOLVER_STATUS_SUCCESS, \
1849  ExcCusparseError( \
1850  deal_II_exceptions::internals::get_cusolver_error_string( \
1851  error_code)))
1852 # else
1853 # define AssertCusolver(error_code) \
1854  { \
1855  (void)(error_code); \
1856  }
1857 # endif
1858 
1859 #endif
1860 
1861 using namespace StandardExceptions;
1862 
1863 DEAL_II_NAMESPACE_CLOSE
1864 
1865 #endif
static ::ExceptionBase & ExcCudaError(const char *arg1)
static ::ExceptionBase & ExcPureFunctionCalled()
static ::ExceptionBase & ExcNeedsFunctionparser()
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
static ::ExceptionBase & ExcImpossibleInDimSpacedim(int arg1, int arg2)
void suppress_stacktrace_in_exceptions()
Definition: exceptions.cc:65
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
static ::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
virtual ~ExceptionBase() noexcept override
Definition: exceptions.cc:115
std::string get_cusolver_error_string(const cusolverStatus_t error_code)
Definition: exceptions.cc:517
void set_additional_assert_output(const char *const p)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcDivideByZero()
void * raw_stacktrace[25]
Definition: exceptions.h:161
virtual void print_info(std::ostream &out) const
Definition: exceptions.cc:210
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)
virtual const char * what() const noexcept override
Definition: exceptions.cc:147
static ::ExceptionBase & ExcNeedsNetCDF()
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
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:124
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void do_issue_error_nothrow(const ExceptionBase &e) noexcept
Definition: exceptions.cc:454
static ::ExceptionBase & ExcOutOfMemory(std::size_t arg1)
std::string get_cusparse_error_string(const cusparseStatus_t error_code)
Definition: exceptions.cc:471
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
#define DeclException0(Exception0)
Definition: exceptions.h:473
void abort(const ExceptionBase &exc) noexcept
Definition: exceptions.cc:408
static ::ExceptionBase & ExcNeedsAssimp()
static ::ExceptionBase & ExcIndexRangeType(T arg1, T arg2, T arg3)
std::string what_str
Definition: exceptions.h:175
unsigned int line
Definition: exceptions.h:128
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
void print_stack_trace(std::ostream &out) const
Definition: exceptions.cc:218
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:1297
void issue_error_nothrow(const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e) noexcept
Definition: exceptions.h:1345
const char * file
Definition: exceptions.h:123
static ::ExceptionBase & ExcCusparseError(std::string arg1)
static ::ExceptionBase & ExcEmptyObject()
void print_exc_data(std::ostream &out) const
Definition: exceptions.cc:178
static ::ExceptionBase & ExcNotMultiple(int arg1, int arg2)
static ::ExceptionBase & ExcNotImplemented()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:564
void generate_message() const
Definition: exceptions.cc:307
char ** stacktrace
Definition: exceptions.h:149
void disable_abort_on_exception()
Definition: exceptions.cc:71
const char * get_exc_name() const
Definition: exceptions.cc:170
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()