summaryrefslogtreecommitdiff
path: root/connectivity/source/commontools/sqlerror.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/commontools/sqlerror.cxx')
-rw-r--r--connectivity/source/commontools/sqlerror.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/connectivity/source/commontools/sqlerror.cxx b/connectivity/source/commontools/sqlerror.cxx
index 9f8608384d1d..50c5968cd7d6 100644
--- a/connectivity/source/commontools/sqlerror.cxx
+++ b/connectivity/source/commontools/sqlerror.cxx
@@ -25,7 +25,6 @@
#include <com/sun/star/sdb/ErrorCondition.hpp>
#include <cppuhelper/exc_hlp.hxx>
-#include <rtl/ustrbuf.hxx>
#include <unotools/resmgr.hxx>
#include <osl/diagnose.h>
@@ -50,7 +49,7 @@ namespace connectivity
// versions of the public SQLError methods which are just delegated to this impl-class
static const OUString& getMessagePrefix();
- OUString getErrorMessage( const ErrorCondition _eCondition, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 );
+ OUString getErrorMessage( const ErrorCondition _eCondition, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 ) const;
static ErrorCode getErrorCode( const ErrorCondition _eCondition );
void raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 );
void raiseException( const ErrorCondition _eCondition, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 );
@@ -59,8 +58,7 @@ namespace connectivity
private:
/// returns the basic error message associated with the given error condition, without any parameter replacements
- OUString
- impl_getErrorMessage( ErrorCondition _eCondition );
+ OUString impl_getErrorMessage( ErrorCondition _eCondition ) const;
/// returns the SQLState associated with the given error condition
static OUString
@@ -81,7 +79,7 @@ namespace connectivity
const OUString& SQLError_Impl::getMessagePrefix()
{
- static const OUString s_sMessagePrefix( "[OOoBase]" );
+ static constexpr OUString s_sMessagePrefix( u"[OOoBase]"_ustr );
return s_sMessagePrefix;
}
@@ -103,7 +101,7 @@ namespace connectivity
_rMessage = _rMessage.replaceAt( nIndex, nPlaceholderLen, *rParamValue );
}
- const char* lcl_getResourceErrorID(const ErrorCondition _eCondition)
+ TranslateId lcl_getResourceErrorID(const ErrorCondition _eCondition)
{
switch (_eCondition)
{
@@ -126,7 +124,7 @@ namespace connectivity
case css::sdb::ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED:
return STR_DATA_CANNOT_SELECT_UNFILTERED;
}
- return nullptr;
+ return {};
}
OUString lcl_getResourceState(const ErrorCondition _eCondition)
@@ -142,7 +140,7 @@ namespace connectivity
}
}
- OUString SQLError_Impl::getErrorMessage( const ErrorCondition _eCondition, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 )
+ OUString SQLError_Impl::getErrorMessage( const ErrorCondition _eCondition, const std::optional<OUString>& _rParamValue1, const std::optional<OUString>& _rParamValue2, const std::optional<OUString>& _rParamValue3 ) const
{
OUString sErrorMessage( impl_getErrorMessage( _eCondition ) );
@@ -220,7 +218,7 @@ namespace connectivity
);
}
- OUString SQLError_Impl::impl_getErrorMessage( ErrorCondition _eCondition )
+ OUString SQLError_Impl::impl_getErrorMessage( ErrorCondition _eCondition ) const
{
OUString sResMessage(Translate::get(lcl_getResourceErrorID(_eCondition), m_aResources));
OSL_ENSURE( !sResMessage.isEmpty(), "SQLError_Impl::impl_getErrorMessage: illegal error condition, or invalid resource!" );
@@ -229,9 +227,10 @@ namespace connectivity
OUString SQLError_Impl::impl_getSQLState( ErrorCondition _eCondition )
{
+ static constexpr OUStringLiteral DEFAULT_STATE = u"S1000";
OUString sState = lcl_getResourceState(_eCondition);
if (sState.isEmpty())
- sState = OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) );
+ sState = DEFAULT_STATE;
return sState;
}