summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Calc.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-09-20 11:05:13 +0200
committerJose <jose@zeroc.com>2017-09-20 11:05:13 +0200
commit7f0816001e085f482f8f9a34b7f8e06435907510 (patch)
tree46807f18b840e1c9816cd9b4aac001c8078d8bce /cpp/src/IcePatch2/Calc.cpp
parentFixed Ice/acm Java7 build failure (diff)
downloadice-7f0816001e085f482f8f9a34b7f8e06435907510.tar.bz2
ice-7f0816001e085f482f8f9a34b7f8e06435907510.tar.xz
ice-7f0816001e085f482f8f9a34b7f8e06435907510.zip
Clean C++ exception code to only throw exception types
- Update C++ code to only throw types derived from C++ exception - Update C++ code to use one-shot constructors to create the exceptions Fix bug ICE-7892
Diffstat (limited to 'cpp/src/IcePatch2/Calc.cpp')
-rw-r--r--cpp/src/IcePatch2/Calc.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index 167d59d797e..47df39335e5 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -203,7 +203,7 @@ main(int argc, char* argv[])
string cwd;
if(IceUtilInternal::getcwd(cwd) != 0)
{
- throw "cannot get the current directory:\n" + IceUtilInternal::lastErrorToString();
+ throw runtime_error("cannot get the current directory:\n" + IceUtilInternal::lastErrorToString());
}
if(!IceUtilInternal::isAbsolutePath(absDataDir))
@@ -230,7 +230,7 @@ main(int argc, char* argv[])
{
if(p->compare(0, absDataDirWithSlash.size(), absDataDirWithSlash) != 0)
{
- throw "`" + *p + "' is not a path in `" + dataDir + "'";
+ throw runtime_error("`" + *p + "' is not a path in `" + dataDir + "'");
}
p->erase(0, absDataDirWithSlash.size());
@@ -290,31 +290,29 @@ main(int argc, char* argv[])
{
LargeFileInfoSeq newInfoSeq = infoSeq;
sort(newInfoSeq.begin(), newInfoSeq.end(), IFileInfoPathLess());
-
- string ex;
+ string reason;
LargeFileInfoSeq::iterator p = newInfoSeq.begin();
while((p = adjacent_find(p, newInfoSeq.end(), IFileInfoPathEqual())) != newInfoSeq.end())
{
do
{
- ex += '\n' + dataDir + '/' + p->path;
+ reason += '\n' + dataDir + '/' + p->path;
++p;
}
while(p < newInfoSeq.end() && IFileInfoPathEqual()(*(p - 1), *p));
}
- if(!ex.empty())
+ if(!reason.empty())
{
- ex = "duplicate files:" + ex;
- throw ex;
+ throw runtime_error("duplicate files:" + reason);
}
}
saveFileInfoSeq(absDataDir, infoSeq);
}
- catch(const string& ex)
+ catch(const exception& ex)
{
- consoleErr << appName << ": " << ex << endl;
+ consoleErr << appName << ": " << ex.what() << endl;
return EXIT_FAILURE;
}
catch(const char* ex)