Hi Karl, thank you very much for your answer! I will implement a wrapper for handling petsc error codes using the html page you mention.
Have a nice day! Cédric ----- Mail original ----- > De: "Karl Rupp" <[email protected]> > À: "Cedric Doucet" <[email protected]>, [email protected] > Envoyé: Vendredi 8 Août 2014 14:16:25 > Objet: Re: [petsc-users] Correct usage of CHKERRXX > > Hi Cedric, > > > I need to call several functions from Petsc in a C++ code. > > I would like to handle manage errors from Petsc with exceptions. > > > > In Petsc's documentation, I found that there exists a macro to do that : > > CHKERRXX. > > > > How does it work? > > It checks for a nonzero error code and returns from the function > immediately if that is the case. Have a look at the implementation here: > http://www.mcs.anl.gov/petsc/petsc-3.5/include/petscerror.h.html > > > Which kind of exception does it throw in case of failure? > > Do you inherit from std::exception? > > Is there an exception for each error code? > > Neither. You would have to write your own wrapper around it, translating > the error codes into exceptions. PETSc cannot use exceptions since it is > a C library. Some people also argue against exceptions because they tend > to bloat the executable for all the roll-back code. > > Best regards, > Karli > >
