Reference documentation for deal.II version Git 0491297983 2019-09-23 09:31:59 +0200
\(\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  "Your program tried to allocate some memory but this "
695  "allocation failed. Typically, this either means that "
696  "you simply do not have enough memory in your system, "
697  "or that you are (erroneously) trying to allocate "
698  "a chunk of memory that is simply beyond all reasonable "
699  "size, for example because the size of the object has "
700  "been computed incorrectly.");
701 
707  int,
708  << "Destroying memory handler while " << arg1
709  << " objects are still allocated.");
710 
715  "An input/output error has occurred. There are a number of "
716  "reasons why this may be happening, both for reading and "
717  "writing operations."
718  "\n\n"
719  "If this happens during an operation that tries to read "
720  "data: First, you may be "
721  "trying to read from a file that doesn't exist or that is "
722  "not readable given its file permissions. Second, deal.II "
723  "uses this error at times if it tries to "
724  "read information from a file but where the information "
725  "in the file does not correspond to the expected format. "
726  "An example would be a truncated file, or a mesh file "
727  "that contains not only sections that describe the "
728  "vertices and cells, but also sections for additional "
729  "data that deal.II does not understand."
730  "\n\n"
731  "If this happens during an operation that tries to write "
732  "data: you may be trying to write to a file to which file "
733  "or directory permissions do not allow you to write. A "
734  "typical example is where you specify an output file in "
735  "a directory that does not exist.");
736 
744  std::string,
745  << "Could not open file " << arg1 << ".");
746 
756  "You are trying to use functionality in deal.II that is "
757  "currently not implemented. In many cases, this indicates "
758  "that there simply didn't appear much of a need for it, or "
759  "that the author of the original code did not have the "
760  "time to implement a particular case. If you hit this "
761  "exception, it is therefore worth the time to look into "
762  "the code to find out whether you may be able to "
763  "implement the missing functionality. If you do, please "
764  "consider providing a patch to the deal.II development "
765  "sources (see the deal.II website on how to contribute).");
766 
788  "This exception -- which is used in many places in the "
789  "library -- usually indicates that some condition which "
790  "the author of the code thought must be satisfied at a "
791  "certain point in an algorithm, is not fulfilled. An "
792  "example would be that the first part of an algorithm "
793  "sorts elements of an array in ascending order, and "
794  "a second part of the algorithm later encounters an "
795  "element that is not larger than the previous one."
796  "\n\n"
797  "There is usually not very much you can do if you "
798  "encounter such an exception since it indicates an error "
799  "in deal.II, not in your own program. Try to come up with "
800  "the smallest possible program that still demonstrates "
801  "the error and contact the deal.II mailing lists with it "
802  "to obtain help.");
803 
812  "You (or a place in the library) are trying to call a "
813  "function that is declared as a virtual function in a "
814  "base class but that has not been overridden in your "
815  "derived class."
816  "\n\n"
817  "This exception happens in cases where the base class "
818  "cannot provide a useful default implementation for "
819  "the virtual function, but where we also do not want "
820  "to mark the function as abstract (i.e., with '=0' at the end) "
821  "because the function is not essential to the class in many "
822  "contexts. In cases like this, the base class provides "
823  "a dummy implementation that makes the compiler happy, but "
824  "that then throws the current exception."
825  "\n\n"
826  "A concrete example would be the 'Function' class. It declares "
827  "the existence of 'value()' and 'gradient()' member functions, "
828  "and both are marked as 'virtual'. Derived classes have to "
829  "override these functions for the values and gradients of a "
830  "particular function. On the other hand, not every function "
831  "has a gradient, and even for those that do, not every program "
832  "actually needs to evaluate it. Consequently, there is no "
833  "*requirement* that a derived class actually override the "
834  "'gradient()' function (as there would be had it been marked "
835  "as abstract). But, since the base class cannot know how to "
836  "compute the gradient, if a derived class does not override "
837  "the 'gradient()' function and it is called anyway, then the "
838  "default implementation in the base class will simply throw "
839  "an exception."
840  "\n\n"
841  "The exception you see is what happens in cases such as the "
842  "one just illustrated. To fix the problem, you need to "
843  "investigate whether the function being called should indeed have "
844  "been called; if the answer is 'yes', then you need to "
845  "implement the missing override in your class.");
846 
851 
856 
864  int,
865  << "You are trying to execute functionality that is "
866  << "impossible in " << arg1
867  << "d or simply does not make any sense.");
868 
877  int,
878  int,
879  << "You are trying to execute functionality that is "
880  << "impossible in dimensions <" << arg1 << "," << arg2
881  << "> or simply does not make any sense.");
882 
883 
888  "In a check in the code, deal.II encountered a zero in "
889  "a place where this does not make sense. See the condition "
890  "that was being checked and that is printed further up "
891  "in the error message to get more information on what "
892  "the erroneous zero corresponds to.");
893 
899  "The object you are trying to access is empty but it makes "
900  "no sense to attempt the operation you are trying on an "
901  "empty object.");
902 
911  std::size_t,
912  std::size_t,
913  << "Dimension " << arg1 << " not equal to " << arg2 << ".");
914 
920  int,
921  int,
922  int,
923  << "Dimension " << arg1 << " neither equal to " << arg2
924  << " nor to " << arg3 << ".");
925 
940  int,
941  int,
942  int,
943  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
944  << arg3 << ")."
945  << (arg2 == arg3 ?
946  " In the current case, this half-open range is in fact empty, "
947  "suggesting that you are accessing an element of an empty "
948  "collection such as a vector that has not been set to the "
949  "correct size." :
950  ""));
951 
967  template <typename T>
970  T,
971  T,
972  T,
973  << "Index " << arg1 << " is not in the half-open range [" << arg2 << ","
974  << arg3 << ")."
975  << (arg2 == arg3 ?
976  " In the current case, this half-open range is in fact empty, "
977  "suggesting that you are accessing an element of an empty "
978  "collection such as a vector that has not been set to the "
979  "correct size." :
980  ""));
981 
986  int,
987  int,
988  << "Number " << arg1 << " must be larger than or equal "
989  << arg2 << ".");
990 
994  template <typename T>
996  T,
997  T,
998  << "Number " << arg1 << " must be larger than or equal "
999  << arg2 << ".");
1000 
1006  int,
1007  int,
1008  << "Division " << arg1 << " by " << arg2
1009  << " has remainder different from zero.");
1010 
1020  "You are trying to use an iterator, but the iterator is "
1021  "in an invalid state. This may indicate that the iterator "
1022  "object has not been initialized, or that it has been "
1023  "moved beyond the end of the range of valid elements.");
1024 
1030  "You are trying to use an iterator, but the iterator is "
1031  "pointing past the end of the range of valid elements. "
1032  "It is not valid to dereference the iterator in this "
1033  "case.");
1034 
1048  DeclException1(ExcMessage, std::string, << arg1);
1049 
1054  "You are trying an operation on a vector that is only "
1055  "allowed if the vector has no ghost elements, but the "
1056  "vector you are operating on does have ghost elements. "
1057  "Specifically, vectors with ghost elements are read-only "
1058  "and cannot appear in operations that write into these "
1059  "vectors."
1060  "\n\n"
1061  "See the glossary entry on 'Ghosted vectors' for more "
1062  "information.");
1063 
1072  "You are trying an operation of the form 'vector=s' with "
1073  "a nonzero scalar value 's'. However, such assignments "
1074  "are only allowed if the right hand side is zero.");
1075 
1081  "You are attempting to use functionality that is only available "
1082  "if deal.II was configured to use LAPACK, but cmake did not "
1083  "find a valid LAPACK library.");
1084 
1092  "You are attempting to use functionality that is only available "
1093  "if deal.II was configured to use NetCDF, but cmake did not "
1094  "find a valid NetCDF library.");
1095 
1101  "You are attempting to use functionality that is only available "
1102  "if deal.II was configured to use the function parser which "
1103  "relies on the muparser library, but cmake did not "
1104  "find a valid muparser library on your system and also did "
1105  "not choose the one that comes bundled with deal.II.");
1106 
1112  "You are attempting to use functionality that is only available "
1113  "if deal.II was configured to use Assimp, but cmake did not "
1114  "find a valid Assimp library.");
1115 
1116 #ifdef DEAL_II_WITH_CUDA
1117 
1123  DeclException1(ExcCudaError, const char *, << arg1);
1128  std::string,
1129  << "There was an error in a cuSPARSE function: " << arg1);
1130 #endif
1131 
1132 
1133 #ifdef DEAL_II_WITH_MPI
1134 
1156  class ExcMPI : public ::ExceptionBase
1157  {
1158  public:
1159  ExcMPI(const int error_code);
1160 
1161  virtual void
1162  print_info(std::ostream &out) const override;
1163 
1164  const int error_code;
1165  };
1166 #endif // DEAL_II_WITH_MPI
1167 } /*namespace StandardExceptions*/
1168 
1169 
1170 
1178 {
1179  namespace internals
1180  {
1188  extern bool allow_abort_on_exception;
1189  } // namespace internals
1190 
1209  void
1210  set_additional_assert_output(const char *const p);
1211 
1222  void
1224 
1238  void
1240 
1248  namespace internals
1249  {
1254  [[noreturn]] void
1255  abort(const ExceptionBase &exc) noexcept;
1256 
1261  {
1272  };
1273 
1291  template <class ExceptionType>
1292  [[noreturn]] void
1294  const char * file,
1295  int line,
1296  const char * function,
1297  const char * cond,
1298  const char * exc_name,
1299  ExceptionType e) {
1300  // Fill the fields of the exception object
1301  e.set_fields(file, line, function, cond, exc_name);
1302 
1303  switch (handling)
1304  {
1306  {
1309  internals::abort(e);
1310  else
1311  {
1312  // We are not allowed to abort, so just throw the error:
1313  throw e;
1314  }
1315  }
1316  case throw_on_exception:
1317  throw e;
1318  // this function should never return (and AssertNothrow can);
1319  // something must have gone wrong in the error handling code for us
1320  // to get this far, so throw an exception.
1321  default:
1323  }
1324  }
1325 
1329  void do_issue_error_nothrow(const ExceptionBase &e) noexcept;
1330 
1339  template <class ExceptionType>
1340  void
1342  int line,
1343  const char * function,
1344  const char * cond,
1345  const char * exc_name,
1346  ExceptionType e) noexcept
1347  {
1348  static_assert(std::is_base_of<ExceptionBase, ExceptionType>::value,
1349  "The provided exception must inherit from ExceptionBase.");
1350  // Fill the fields of the exception object
1351  e.set_fields(file, line, function, cond, exc_name);
1352  // avoid moving a bunch of code into the header by dispatching to
1353  // another function:
1355  }
1356 #ifdef DEAL_II_WITH_CUDA
1357 
1362  std::string
1363  get_cusparse_error_string(const cusparseStatus_t error_code);
1364 
1370  std::string
1371  get_cusolver_error_string(const cusolverStatus_t error_code);
1372 #endif
1373  } /*namespace internals*/
1374 
1375 } /*namespace deal_II_exceptions*/
1376 
1377 
1378 
1405 #ifdef DEBUG
1406 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1407 # define Assert(cond, exc) \
1408  { \
1409  if (__builtin_expect(!(cond), false)) \
1410  ::deal_II_exceptions::internals::issue_error_noreturn( \
1411  ::deal_II_exceptions::internals:: \
1412  abort_or_throw_on_exception, \
1413  __FILE__, \
1414  __LINE__, \
1415  __PRETTY_FUNCTION__, \
1416  #cond, \
1417  #exc, \
1418  exc); \
1419  }
1420 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1421 # define Assert(cond, exc) \
1422  { \
1423  if (!(cond)) \
1424  ::deal_II_exceptions::internals::issue_error_noreturn( \
1425  ::deal_II_exceptions::internals:: \
1426  abort_or_throw_on_exception, \
1427  __FILE__, \
1428  __LINE__, \
1429  __PRETTY_FUNCTION__, \
1430  #cond, \
1431  #exc, \
1432  exc); \
1433  }
1434 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1435 #else
1436 # define Assert(cond, exc) \
1437  {}
1438 #endif
1439 
1440 
1441 
1469 #ifdef DEBUG
1470 # ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1471 # define AssertNothrow(cond, exc) \
1472  { \
1473  if (__builtin_expect(!(cond), false)) \
1474  ::deal_II_exceptions::internals::issue_error_nothrow( \
1475  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1476  }
1477 # else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1478 # define AssertNothrow(cond, exc) \
1479  { \
1480  if (!(cond)) \
1481  ::deal_II_exceptions::internals::issue_error_nothrow( \
1482  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #exc, exc); \
1483  }
1484 # endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1485 #else
1486 # define AssertNothrow(cond, exc) \
1487  {}
1488 #endif
1489 
1518 #ifdef DEAL_II_HAVE_BUILTIN_EXPECT
1519 # define AssertThrow(cond, exc) \
1520  { \
1521  if (__builtin_expect(!(cond), false)) \
1522  ::deal_II_exceptions::internals::issue_error_noreturn( \
1523  ::deal_II_exceptions::internals::throw_on_exception, \
1524  __FILE__, \
1525  __LINE__, \
1526  __PRETTY_FUNCTION__, \
1527  #cond, \
1528  #exc, \
1529  exc); \
1530  }
1531 #else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1532 # define AssertThrow(cond, exc) \
1533  { \
1534  if (!(cond)) \
1535  ::deal_II_exceptions::internals::issue_error_noreturn( \
1536  ::deal_II_exceptions::internals::throw_on_exception, \
1537  __FILE__, \
1538  __LINE__, \
1539  __PRETTY_FUNCTION__, \
1540  #cond, \
1541  #exc, \
1542  exc); \
1543  }
1544 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
1545 
1567 #define AssertDimension(dim1, dim2) \
1568  Assert(static_cast<typename ::internal::argument_type<void( \
1569  typename std::common_type<decltype(dim1), \
1570  decltype(dim2)>::type)>::type>(dim1) == \
1571  static_cast<typename ::internal::argument_type<void( \
1572  typename std::common_type<decltype(dim1), \
1573  decltype(dim2)>::type)>::type>(dim2), \
1574  ::ExcDimensionMismatch((dim1), (dim2)))
1575 
1576 
1595 #define AssertVectorVectorDimension(VEC, DIM1, DIM2) \
1596  AssertDimension(VEC.size(), DIM1); \
1597  for (const auto &subvector : VEC) \
1598  { \
1599  (void)subvector; \
1600  AssertDimension(subvector.size(), DIM2); \
1601  }
1602 
1603 namespace internal
1604 {
1605  // Workaround to allow for commas in template parameter lists
1606  // in preprocessor macros as found in
1607  // https://stackoverflow.com/questions/13842468/comma-in-c-c-macro
1608  template <typename T>
1609  struct argument_type;
1610  template <typename T, typename U>
1611  struct argument_type<T(U)>
1612  {
1613  using type = U;
1614  };
1615 } // namespace internal
1616 
1637 #define AssertIndexRange(index, range) \
1638  Assert( \
1639  static_cast<typename ::internal::argument_type<void( \
1640  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1641  type>(index) < \
1642  static_cast<typename ::internal::argument_type<void( \
1643  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1644  type>(range), \
1645  ExcIndexRangeType<typename ::internal::argument_type<void( \
1646  typename std::common_type<decltype(index), decltype(range)>::type)>:: \
1647  type>((index), 0, (range)))
1648 
1669 #define AssertIsFinite(number) \
1670  Assert(::numbers::is_finite(number), \
1671  ::ExcNumberNotFinite(std::complex<double>(number)))
1672 
1673 #ifdef DEAL_II_WITH_MPI
1674 
1695 # define AssertThrowMPI(error_code) \
1696  AssertThrow(error_code == MPI_SUCCESS, ::ExcMPI(error_code))
1697 #else
1698 # define AssertThrowMPI(error_code) \
1699  {}
1700 #endif // DEAL_II_WITH_MPI
1701 
1702 #ifdef DEAL_II_WITH_CUDA
1703 
1721 # ifdef DEBUG
1722 # define AssertCuda(error_code) \
1723  Assert(error_code == cudaSuccess, \
1724  ::ExcCudaError(cudaGetErrorString(error_code)))
1725 # else
1726 # define AssertCuda(error_code) \
1727  { \
1728  (void)(error_code); \
1729  }
1730 # endif
1731 
1749 # ifdef DEBUG
1750 # define AssertNothrowCuda(error_code) \
1751  AssertNothrow(error_code == cudaSuccess, \
1752  ::ExcCudaError(cudaGetErrorString(error_code)))
1753 # else
1754 # define AssertNothrowCuda(error_code) \
1755  { \
1756  (void)(error_code); \
1757  }
1758 # endif
1759 
1778 # ifdef DEBUG
1779 # define AssertCusparse(error_code) \
1780  Assert( \
1781  error_code == CUSPARSE_STATUS_SUCCESS, \
1782  ExcCusparseError( \
1783  deal_II_exceptions::internals::get_cusparse_error_string( \
1784  error_code)))
1785 # else
1786 # define AssertCusparse(error_code) \
1787  { \
1788  (void)(error_code); \
1789  }
1790 # endif
1791 
1809 # ifdef DEBUG
1810 # define AssertNothrowCusparse(error_code) \
1811  AssertNothrow( \
1812  error_code == CUSPARSE_STATUS_SUCCESS, \
1813  ExcCusparseError( \
1814  deal_II_exceptions::internals::get_cusparse_error_string( \
1815  error_code)))
1816 # else
1817 # define AssertNothrowCusparse(error_code) \
1818  { \
1819  (void)(error_code); \
1820  }
1821 # endif
1822 
1841 # ifdef DEBUG
1842 # define AssertCusolver(error_code) \
1843  Assert( \
1844  error_code == CUSOLVER_STATUS_SUCCESS, \
1845  ExcCusparseError( \
1846  deal_II_exceptions::internals::get_cusolver_error_string( \
1847  error_code)))
1848 # else
1849 # define AssertCusolver(error_code) \
1850  { \
1851  (void)(error_code); \
1852  }
1853 # endif
1854 
1855 #endif
1856 
1857 using namespace StandardExceptions;
1858 
1859 DEAL_II_NAMESPACE_CLOSE
1860 
1861 #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 & ExcOutOfMemory()
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
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:1293
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:1341
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()