[fdo-dev] Standard exceptions handling practice

Mateusz Loskot mateusz at loskot.net
Fri Sep 1 14:11:29 EDT 2006


Greg Boone wrote:
> When dealing with 3rd party exceptions, we try our *best* to catch
> these exceptions in the provider code base and translate the contents
> of the exception into an FdoException. We then throw the
> FdoException. Our main clients such as Map and MapGuide are set up to
> catch instances of FdoException when executing FDO logic and allowing
> other exceptions to be thrown when executing provider code could
> severely compromise their error handling strategies.

I understand.
So, does following example conforms the FDO exceptions
handling strategy?
What message should I pass to NlsMsgGet() ?
How about forwarding std::exception to FdoException hierarchy,
for example to retrieve what() message?

void foo()
{
   try
   {
      // operation that throws exception derived
      // from standard ex. type std::exception
      bar();
   }
   catch(std::exception& ex)
   {
      throw FdoException::Create(
               NlsMsgGet(XYZ_123_FAIL_BAR, "bar() failed"), ex);
   }
}

It's quite important to know how to deal/translate standard
exceptions to FDO exceptions.
STL and Boost libraries use std::exception as a base type for their
exceptions hierarchy.

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




More information about the Fdo_dev mailing list