Tag: cws_src680_dba24c User: fs Date: 2007-09-18 20:03:45+0000 Modified: dba/connectivity/source/commontools/sqlerror.cxx
Log: +getSQLException File Changes: Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: sqlerror.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/sqlerror.cxx?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +40 -8 -------------------- --- sqlerror.cxx 2007-09-18 13:23:23+0000 1.1.2.4 +++ sqlerror.cxx 2007-09-18 20:03:42+0000 1.1.2.5 @@ -4,9 +4,9 @@ * * $RCSfile: sqlerror.cxx,v $ * - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * - * last change: $Author: fs $ $Date: 2007/09/18 13:23:23 $ + * last change: $Author: fs $ $Date: 2007/09/18 20:03:42 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -83,13 +83,22 @@ void raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ); void raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ); void raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ); + SQLException getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ); private: + /// returns the basic error message associated with the given error condition, without any parameter replacements ::rtl::OUString impl_getErrorMessage( const ErrorCondition& _eCondition ); + + /// returns the SQLState associated with the given error condition ::rtl::OUString impl_getSQLState( const ErrorCondition& _eCondition ); + /// returns an SQLException describing the given error condition + SQLException + impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, + const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ); + /// initializes our resource bundle bool impl_initResources(); @@ -212,18 +221,34 @@ Any aException( NULL, _rExceptionType ); // fill it - SQLException* pException = const_cast< SQLException* >( static_cast< const SQLException* >( aException.getValue() ) ); - - pException->Message = getErrorMessage( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 ); - pException->Context = _rxContext; - pException->SQLState = getSQLState( _eCondition ); - pException->ErrorCode = getErrorCode( _eCondition ); + SQLException* pException = static_cast< SQLException* >( aException.pData ); + *pException = impl_buildSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 ); // throw it ::cppu::throwException( aException ); } //-------------------------------------------------------------------- + SQLException SQLError_Impl::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, + const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) + { + return impl_buildSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 ); + } + + //-------------------------------------------------------------------- + SQLException SQLError_Impl::impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, + const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) + { + return SQLException( + getErrorMessage( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 ), + _rxContext, + getSQLState( _eCondition ), + getErrorCode( _eCondition ), + Any() + ); + } + + //-------------------------------------------------------------------- ::rtl::OUString SQLError_Impl::impl_getErrorMessage( const ErrorCondition& _eCondition ) { ::rtl::OUStringBuffer aMessage; @@ -328,6 +353,13 @@ m_pImpl->raiseTypedException( _eCondition, _rxContext, _rExceptionType, _rParamValue1, _rParamValue2, _rParamValue3 ); } + //-------------------------------------------------------------------- + SQLException SQLError::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, + const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const + { + return m_pImpl->getSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 ); + } + //........................................................................ } // namespace connectivity //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
