TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/OfxhException.hpp
Go to the documentation of this file.
00001 #ifndef _OFXH_EXCEPTION_HPP_
00002 #define _OFXH_EXCEPTION_HPP_
00003 
00004 #include "OfxhCore.hpp"
00005 #include "OfxhUtilities.hpp"
00006 
00007 #include <tuttle/host/exceptions.hpp>
00008 
00009 #include <boost/throw_exception.hpp>
00010 #include <boost/exception/exception.hpp>
00011 
00012 #include <stdexcept>
00013 
00014 namespace tuttle {
00015 namespace host {
00016 namespace ofx {
00017 
00018 /**
00019  * exception, representing an OfxStatus
00020  */
00021 class OfxhException : virtual public ::std::exception
00022         , virtual public ::boost::exception
00023         , virtual public ::boost::backtrace
00024 {
00025 OfxStatus _stat;
00026 
00027 public:
00028         explicit OfxhException( const std::string& what )
00029                 : ::boost::exception()
00030                 , _stat( kOfxStatErrUnknown )
00031         {
00032                 *this << ::tuttle::exception::dev() + what;
00033         }
00034 
00035         explicit OfxhException( OfxStatus stat )
00036                 : ::boost::exception()
00037                 , _stat( stat )
00038         {
00039                 *this << ::tuttle::exception::ofxStatus(stat);
00040         }
00041 
00042         explicit OfxhException( OfxStatus stat, const std::string& what )
00043                 : ::boost::exception()
00044                 , _stat( stat )
00045         {
00046                 *this << ::tuttle::exception::ofxStatus(stat);
00047                 *this << ::tuttle::exception::dev() + what;
00048         }
00049 
00050         /// get the status
00051         OfxStatus getStatus() const
00052         {
00053                 return _stat;
00054         }
00055 
00056         ///@todo tuttle : mapStatusEnumToStr... in tuttle common
00057         std::string getStatusStr() const
00058         {
00059                 return ofx::mapStatusToString( _stat );
00060         }
00061 
00062 };
00063 
00064 //#if !defined(WINDOWS) || !defined(SWIG)
00065 // #define OFX_EXCEPTION_SPEC throw(tuttle::host::ofx::OfxhException)
00066 //#else
00067 #define OFX_EXCEPTION_SPEC
00068 //#endif
00069 
00070 }
00071 }
00072 }
00073 
00074 #endif
00075