Okay, that sounds right. I was always using CHKERRXX.<div><br></div><div>   Matt<br><br><div class="gmail_quote">On Tue, May 11, 2010 at 7:56 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
   I've been trying to understand the use of CHKERRXX() PetscErrorCxx(), PetscTraceBackErrorHandlerCxx() and think it is messed up.<br>
<br>
   Assumptions<br>
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)<br>
2) PETSc c code cannot call PETSc c++ code<br>
3) PETSc c++ code uses C++ exceptions for error handling, NOT return values.<br>
are these correct?<br>
<br>
   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().<br>

<br>
   I have started to reorganize this.<br>
<br>
 Turned PetscTraceBackErrorHandlerCxx() into a regular handler that can be pushed. Put the stream it uses into the handler context.<br>
Removed PetscErrorCxx()<br>
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.<br>
Changed CHKERRXX() to simply call PetscError() with the appropriate PetscErrorType of PETSC_ERROR_IN_CXX<br>
Not yet tested the PetscTraceBackErrorHandlerCxx()<br>
<font color="#888888"><br>
   Barry<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>

</div>