Okay, that sounds right. I was always using CHKERRXX. Matt
On Tue, May 11, 2010 at 7:56 PM, Barry Smith <bsmith at mcs.anl.gov> wrote: > > > I've been trying to understand the use of CHKERRXX() PetscErrorCxx(), > PetscTraceBackErrorHandlerCxx() and think it is messed up. > > Assumptions > 1) real PETSc c++ code (that is PETSc code that uses C++ constructs, has > .cxx extensions) can call PETSc c code (the normal old PETSc source) > 2) PETSc c code cannot call PETSc c++ code > 3) PETSc c++ code uses C++ exceptions for error handling, NOT return > values. > are these correct? > > Thus when PETSc c++ code calls PETSc c code it needs to translate any > PETSc error return codes to C++ exceptions. This is currently done by > CHKERRXX() being a macro to PetscErrorCxx() that then calls > PetscTraceBackErrorHandlerCxx() that actually generates the exception. But > PetscErrorCxx() is not really the same thing as calling PetscError and > PetscTraceBackErrorHandlerCxx() is not really a C++ version of > PetscTraceBackErrorHandler(). Plus PetscTraceBackErrorHandlerCxx() is not an > error handler because it cannot be set with PetscPushErrorHandler(). > > I have started to reorganize this. > > Turned PetscTraceBackErrorHandlerCxx() into a regular handler that can be > pushed. Put the stream it uses into the handler context. > Removed PetscErrorCxx() > Added to PetscError() to automatically generate an exception if the caller > is a C++ routine; as indicated by the PetscErrorType flag that is passed in. > Changed CHKERRXX() to simply call PetscError() with the appropriate > PetscErrorType of PETSC_ERROR_IN_CXX > Not yet tested the PetscTraceBackErrorHandlerCxx() > > Barry > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20100511/907446b2/attachment.html>
