LibreOffice Module connectivity (master) 1
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
connectivity::SQLError Class Reference

a class which provides helpers for working with SQLErrors More...

#include <sqlerror.hxx>

Public Member Functions

 SQLError ()
 
 ~SQLError ()
 
OUString getErrorMessage (const ErrorCondition _eCondition) const
 returns the message associated with a given error condition, after (optionally) replacing a placeholder with a given string More...
 
void raiseException (const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const std::optional< OUString > &_rParamValue1=std::nullopt, const std::optional< OUString > &_rParamValue2=std::nullopt, const std::optional< OUString > &_rParamValue3=std::nullopt) const
 throws an SQLException describing the given error condition More...
 
void raiseException (const ErrorCondition _eCondition) const
 throws an SQLException describing the given error condition More...
 
void raiseTypedException (const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const css::uno::Type &_rExceptionType) const
 raises a typed exception, that is, a UNO exception which is derived from css::sdbc::SQLException More...
 
css::sdbc::SQLException getSQLException (const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const std::optional< OUString > &_rParamValue1=std::nullopt, const std::optional< OUString > &_rParamValue2=std::nullopt, const std::optional< OUString > &_rParamValue3=std::nullopt) const
 retrieves an SQLException object which contains information about the given error condition More...
 

Static Public Member Functions

static ErrorCode getErrorCode (const ErrorCondition _eCondition)
 returns the error code associated with a given error condition More...
 
static const OUString & getMessagePrefix ()
 returns the prefix which is used for OpenOffice.org Base's error messages More...
 

Private Attributes

std::shared_ptr< SQLError_Implm_pImpl
 

Detailed Description

a class which provides helpers for working with SQLErrors

In particular, this class provides vendor-specific error codes (where the vendor is OpenOffice.org Base), which can be used in OOo's various database drivers, and checked in application-level code, to properly recognize highly specific error conditions.

See also
css::sdb::ErrorCondition

Definition at line 58 of file sqlerror.hxx.

Constructor & Destructor Documentation

◆ SQLError()

connectivity::SQLError::SQLError ( )

Definition at line 237 of file sqlerror.cxx.

References m_pImpl, and make_shared().

◆ ~SQLError()

connectivity::SQLError::~SQLError ( )

Definition at line 243 of file sqlerror.cxx.

Member Function Documentation

◆ getErrorCode()

ErrorCode connectivity::SQLError::getErrorCode ( const ErrorCondition  _eCondition)
static

returns the error code associated with a given error condition

See also
getErrorMessage
css::sdb::ErrorCondition
css::sdbc::SQLException::ErrorCode

Definition at line 260 of file sqlerror.cxx.

References connectivity::SQLError_Impl::getErrorCode().

◆ getErrorMessage()

OUString connectivity::SQLError::getErrorMessage ( const ErrorCondition  _eCondition) const

returns the message associated with a given error condition, after (optionally) replacing a placeholder with a given string

Some error messages need to contain references to runtime-dependent data (say, the name of a concrete table in the database), which in the resource file's strings are represented by a placeholder, namely $1$, $2, and so on. This method allows to retrieve such an error message, and replace up to 3 placeholders with their concrete values.

In a non-product build, assertions will fire if the number of placeholders in the message's resource string does not match the number of passed parameter values.

As specified in the css::sdb::ErrorCondition type, error messages thrown by core components of OpenOffice.org Base will contain a standardized prefix "[OOoBase]" in every message.

See also
css::sdb::ErrorCondition

Definition at line 254 of file sqlerror.cxx.

References m_pImpl.

◆ getMessagePrefix()

const OUString & connectivity::SQLError::getMessagePrefix ( )
static

returns the prefix which is used for OpenOffice.org Base's error messages

As specified in the css::sdb::ErrorCondition type, error messages thrown by core components of OpenOffice.org Base will contain a standardized prefix in every message. getBaseErrorMessagePrefix returns this prefix, so clients of such error messages might decide to strip this prefix before presenting the message to the user, or use it to determine whether a concrete error has been raised by a OpenOffice.org core component.

Definition at line 248 of file sqlerror.cxx.

References connectivity::SQLError_Impl::getMessagePrefix().

◆ getSQLException()

SQLException connectivity::SQLError::getSQLException ( const ErrorCondition  _eCondition,
const css::uno::Reference< css::uno::XInterface > &  _rxContext,
const std::optional< OUString > &  _rParamValue1 = std::nullopt,
const std::optional< OUString > &  _rParamValue2 = std::nullopt,
const std::optional< OUString > &  _rParamValue3 = std::nullopt 
) const

retrieves an SQLException object which contains information about the given error condition

Parameters
_eConditionthe ErrorCondition which hit you
_rxContextthe context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member.
_rParamValue1a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the first placeholder in this message.
_rParamValue2a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the second placeholder in this message.
_rParamValue3a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the third placeholder in this message.
See also
getErrorMessage
getErrorCode

Definition at line 285 of file sqlerror.cxx.

References m_pImpl.

Referenced by connectivity::evoab::OEvoabResultSet::construct(), and connectivity::OSQLParseTreeIterator::impl_locateRecordSource().

◆ raiseException() [1/2]

void connectivity::SQLError::raiseException ( const ErrorCondition  _eCondition) const

throws an SQLException describing the given error condition

The thrown SQLException will contain the OOo-specific error code which derives from the given error condition, and the error message associated with that condition.

Note: You should prefer the version of raiseException which takes an additional Context parameter, since this allows clients of your exception to examine where the error occurred.

Parameters
_eConditionthe ErrorCondition which hit you
See also
getErrorMessage
getErrorCode

Definition at line 272 of file sqlerror.cxx.

References m_pImpl.

◆ raiseException() [2/2]

void connectivity::SQLError::raiseException ( const ErrorCondition  _eCondition,
const css::uno::Reference< css::uno::XInterface > &  _rxContext,
const std::optional< OUString > &  _rParamValue1 = std::nullopt,
const std::optional< OUString > &  _rParamValue2 = std::nullopt,
const std::optional< OUString > &  _rParamValue3 = std::nullopt 
) const

throws an SQLException describing the given error condition

The thrown SQLException will contain the OOo-specific error code which derives from the given error condition, and the error message associated with that condition.

Parameters
_eConditionthe ErrorCondition which hit you
_rxContextthe context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member.
_rParamValue1a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the first placeholder in this message.
_rParamValue2a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the second placeholder in this message.
_rParamValue3a runtime-dependent value which should be filled into the error message which is associated with <arg>_eCondition</arg>, replacing the third placeholder in this message.
See also
getErrorMessage
getErrorCode

References raiseException().

Referenced by connectivity::OSQLParseNode::impl_parseTableNameNodeToString_throw().

◆ raiseTypedException()

void connectivity::SQLError::raiseTypedException ( const ErrorCondition  _eCondition,
const css::uno::Reference< css::uno::XInterface > &  _rxContext,
const css::uno::Type &  _rExceptionType 
) const

raises a typed exception, that is, a UNO exception which is derived from css::sdbc::SQLException

Parameters
_eConditionthe ErrorCondition which hit you
_rxContextthe context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member.
_rExceptionTypethe type of the exception to throw. This type must specify an exception class derived from css::sdbc::SQLException.
Exceptions
::std::bad_castif <arg>_rExceptionType</arg> does not specify an exception class derived from css::sdbc::SQLException.
See also
getErrorMessage
getErrorCode

Definition at line 278 of file sqlerror.cxx.

References m_pImpl.

Member Data Documentation

◆ m_pImpl

std::shared_ptr< SQLError_Impl > connectivity::SQLError::m_pImpl
private

The documentation for this class was generated from the following files: