summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-10-12 22:02:15 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-10-14 15:37:17 +0200
commit176e8cf09a527438ec9b2b20ba2df23fa45226bc (patch)
tree76897d74143771a9ee9249c49bbe91da9ffa0433 /ucb/source
parent328d6aae9e2b7a73f6672800629230f5b46d15b1 (diff)
Use exception ctors, instead of setting members later
Avoids overwriting source location in message Change-Id: Ia0290c7dd1ab3ea1357712a27ecab75c7b583dd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157893 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/file/filglob.cxx39
-rw-r--r--ucb/source/ucp/file/filinsreq.cxx16
-rw-r--r--ucb/source/ucp/file/filstr.cxx4
3 files changed, 20 insertions, 39 deletions
diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx
index a86716509a24..a5097f51117e 100644
--- a/ucb/source/ucp/file/filglob.cxx
+++ b/ucb/source/ucp/file/filglob.cxx
@@ -546,17 +546,13 @@ namespace fileaccess {
else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE )
// Overwrite = false and file exists
{
- NameClashException excep;
- excep.Name = getTitle(aUncPath);
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = Reference<XInterface>( xComProc, UNO_QUERY );
- excep.Message = "file exists and overwrite forbidden";
+ NameClashException excep("file exists and overwrite forbidden",
+ Reference<XInterface>(xComProc, UNO_QUERY),
+ InteractionClassification_ERROR, OUString(getTitle(aUncPath)));
cancelCommandExecution( Any(excep), xEnv );
}
else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR )
{
- InteractiveAugmentedIOException excep;
- excep.Code = IOErrorCode_INVALID_CHARACTER;
PropertyValue prop;
prop.Name = "ResourceName";
prop.Handle = -1;
@@ -566,10 +562,9 @@ namespace fileaccess {
rtl_UriDecodeWithCharset,
RTL_TEXTENCODING_UTF8));
prop.Value <<= aClashingName;
- excep.Arguments = { Any(prop) };
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = Reference<XInterface>( xComProc, UNO_QUERY );
- excep.Message = "the name contained invalid characters";
+ InteractiveAugmentedIOException excep(
+ "the name contained invalid characters", Reference<XInterface>(xComProc, UNO_QUERY),
+ InteractionClassification_ERROR, IOErrorCode_INVALID_CHARACTER, { Any(prop) });
if(isHandled)
throw excep;
cancelCommandExecution( Any(excep), xEnv );
@@ -583,11 +578,8 @@ namespace fileaccess {
}
else if( errorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR )
{
- NameClashException excep;
- excep.Name = getTitle(aUncPath);
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = xComProc;
- excep.Message = "folder exists and overwrite forbidden";
+ NameClashException excep("folder exists and overwrite forbidden", xComProc,
+ InteractionClassification_ERROR, OUString(getTitle(aUncPath)));
if(isHandled)
throw excep;
cancelCommandExecution( Any(excep), xEnv );
@@ -835,21 +827,18 @@ namespace fileaccess {
else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY ||
errorCode == TASKHANDLING_NAMECLASH_FOR_MOVE )
{
- NameClashException excep;
- excep.Name = getTitle(aUncPath);
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = Reference<XInterface>( xComProc, UNO_QUERY );
- excep.Message = "name clash during copy or move";
+ NameClashException excep("name clash during copy or move",
+ Reference<XInterface>(xComProc, UNO_QUERY),
+ InteractionClassification_ERROR, OUString(getTitle(aUncPath)));
cancelCommandExecution(Any(excep), xEnv);
}
else if( errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE ||
errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY )
{
- UnsupportedNameClashException excep;
- excep.NameClash = minorCode;
- excep.Context = Reference<XInterface>( xComProc, UNO_QUERY );
- excep.Message = "name clash value not supported during copy or move";
+ UnsupportedNameClashException excep(
+ "name clash value not supported during copy or move",
+ Reference<XInterface>(xComProc, UNO_QUERY), minorCode);
cancelCommandExecution(Any(excep), xEnv);
}
diff --git a/ucb/source/ucp/file/filinsreq.cxx b/ucb/source/ucp/file/filinsreq.cxx
index 3e20f8bee68e..0b8ebfb5395e 100644
--- a/ucb/source/ucp/file/filinsreq.cxx
+++ b/ucb/source/ucp/file/filinsreq.cxx
@@ -55,25 +55,19 @@ XInteractionRequestImpl::XInteractionRequestImpl(
Any aAny;
if(nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR)
{
- NameClashException excep;
- excep.Name = aClashingName;
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = m_xOrigin;
- excep.Message = "folder exists and overwrite forbidden";
+ NameClashException excep("folder exists and overwrite forbidden", m_xOrigin,
+ InteractionClassification_ERROR, aClashingName);
aAny <<= excep;
}
else if(nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR)
{
- InteractiveAugmentedIOException excep;
- excep.Code = IOErrorCode_INVALID_CHARACTER;
PropertyValue prop;
prop.Name = "ResourceName";
prop.Handle = -1;
prop.Value <<= aClashingName;
- excep.Arguments = { Any(prop) };
- excep.Classification = InteractionClassification_ERROR;
- excep.Context = m_xOrigin;
- excep.Message = "the name contained invalid characters";
+ InteractiveAugmentedIOException excep("the name contained invalid characters", m_xOrigin,
+ InteractionClassification_ERROR,
+ IOErrorCode_INVALID_CHARACTER, { Any(prop) });
aAny <<= excep;
}
diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx
index 2e49a7c8f8c2..70c235da7d9b 100644
--- a/ucb/source/ucp/file/filstr.cxx
+++ b/ucb/source/ucp/file/filstr.cxx
@@ -212,9 +212,7 @@ XStream_impl::closeStream()
osl::FileBase::RC err = m_aFile.close();
if( err != osl::FileBase::E_None ) {
- io::IOException ex;
- ex.Message = "could not close file";
- throw ex;
+ throw io::IOException("could not close file");
}
m_nIsOpen = false;