" The former is for logic errors inherent in the program that cannot be recovered from -- say, trying to dereference triangulation.end()"
Of course, it does not make sense to dereference such an iterator. That's the reason why I wanted to catch this operation, and do something else instead. In my case, aborting the program is absolutely not necessary as I would have a workaround. But, if I understand you, there is no way for me to catch the exception from my question, right? Best Simon Wolfgang Bangerth <bange...@colostate.edu> schrieb am So., 30. Juli 2023, 18:33: > > Simon, > > > I want to catch exceptions thrown by fePointEval.reinit(...), > > where fePointEval is an object of type FEPointEvaluation. > > > > Here is a snippet of code demonstrating the issue: > > > > try > > { > > fePointEval.reinit(...); > > } > > catch(dealii::ExceptionBase & exception) > > { > > std::cout<<"exception is catched"<<std::endl; > > throw MyClass(...); > > } > > > > where MyClass is derived from dealii::ExceptionBase. > > > > The exception ExcDereferenceInvalidCell is definitely thrown because the > message > > " You tried to dereference a cell iterator.... " > > is printed on my screen, if I try to evaluate the function attached to > the > > FEPointEvaluation > > object outside its domain. > > The documentation of deal.II rarely is clear about what "throwing an > exception" means. That depends on whether you use Assert or AssertThrow. > The > former is for logic errors inherent in the program that cannot be > recovered > from -- say, trying to dereference triangulation.end(). You need to fix > the > program to deal with this, and so we use Assert which simply aborts the > program (even though perhaps the documentation may say that it "throws the > exception") after showing the error message. > > We use AssertThrow (which really does 'throw' an exception) for situations > that are run-time errors. Say the file you opened cannot be read, or > you're > out of memory -- in general, for situations where the *program* is > correct, > but perhaps its *input* is not. > > Best > W. > > -- > ------------------------------------------------------------------------ > Wolfgang Bangerth email: bange...@colostate.edu > www: http://www.math.colostate.edu/~bangerth/ > > > -- > The deal.II project is located at http://www.dealii.org/ > For mailing list/forum options, see > https://groups.google.com/d/forum/dealii?hl=en > --- > You received this message because you are subscribed to the Google Groups > "deal.II User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to dealii+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/e3b7f84f-d4ee-5854-83a4-add287e86415%40colostate.edu > . > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAM50jEs%3DQUou46YHjpnEdcSU9Xp8zzJyJ7FtXS_O0N4Lbo9Gnw%40mail.gmail.com.