[fdo-internals] Unwinding FDO exceptions

Mateusz Loskot mateusz at loskot.net
Sun Feb 4 02:34:10 EST 2007


Hello,

I'm not sure I understand how to process the roll of FDO exceptions,
so I'd like to ask for confirmation if I'm correct or not.

Here are blocks of nested try-catch that mimic situation in which an
exception is thrown by a callee and re-thrown by a caller, and so on.
In the catch clause, is presented the idea of unwinding nested
exception, using some pseudo-code to make the example simpler.

//------------------------------------
try
{
  try
  {
    try
    {
      throw FdoException::Create(L"First exception");
    }
    catch (FdoException* ex)
    {
      throw FdoException::Create(L"Second caused by first", ex);
    }
  }
  catch (FdoException* ex)
  {
      throw FdoException::Create(L"Third caused by second", ex);
  }
}
catch (FdoException* ex)
{
  // echo is a pseudo-code representing stdout action
  echo "*** FDO FAILURE ***\n"
  echo ex->GetExceptionMessage()

  FdoPtr<FdoException> cause(ex->GetCause());
  while(NULL != cause)
  {
    echo "*** " + cause->GetExceptionMessage() + "\n"

    cause = cause->GetCause();
  }
  ex->Release();
}
//------------------------------------


And here is the output:

*** FDO FAILURE ***
  *** Third caused by second
   *** Second caused by first
    *** First exception


Is this output correct and as usually expected in FDO?
Is this correct to assume that exceptions are
queued as in FILO, First In - Last Out ?


Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net


More information about the fdo-internals mailing list