LibreOffice Module connectivity (master) 1
|
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_Impl > | m_pImpl |
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.
Definition at line 58 of file sqlerror.hxx.
connectivity::SQLError::SQLError | ( | ) |
Definition at line 237 of file sqlerror.cxx.
References m_pImpl, and make_shared().
connectivity::SQLError::~SQLError | ( | ) |
Definition at line 243 of file sqlerror.cxx.
|
static |
returns the error code associated with a given error condition
Definition at line 260 of file sqlerror.cxx.
References connectivity::SQLError_Impl::getErrorCode().
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.
Definition at line 254 of file sqlerror.cxx.
References m_pImpl.
|
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().
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
_eCondition | the ErrorCondition which hit you |
_rxContext | the context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member. |
_rParamValue1 | a 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. |
_rParamValue2 | a 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. |
_rParamValue3 | a 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. |
Definition at line 285 of file sqlerror.cxx.
References m_pImpl.
Referenced by connectivity::evoab::OEvoabResultSet::construct(), and connectivity::OSQLParseTreeIterator::impl_locateRecordSource().
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.
_eCondition | the ErrorCondition which hit you |
Definition at line 272 of file sqlerror.cxx.
References m_pImpl.
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.
_eCondition | the ErrorCondition which hit you |
_rxContext | the context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member. |
_rParamValue1 | a 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. |
_rParamValue2 | a 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. |
_rParamValue3 | a 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. |
References raiseException().
Referenced by connectivity::OSQLParseNode::impl_parseTableNameNodeToString_throw().
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
_eCondition | the ErrorCondition which hit you |
_rxContext | the context in which the error occurred. This will be filled in as <member scope="css::uno">Exception::Context</member> member. |
_rExceptionType | the type of the exception to throw. This type must specify an exception class derived from css::sdbc::SQLException. |
::std::bad_cast | if <arg>_rExceptionType</arg> does not specify an exception class derived from css::sdbc::SQLException. |
Definition at line 278 of file sqlerror.cxx.
References m_pImpl.
|
private |
Definition at line 230 of file sqlerror.hxx.
Referenced by getErrorMessage(), getSQLException(), raiseException(), and raiseTypedException().