diff options
author | Jose <jose@zeroc.com> | 2017-09-20 11:05:13 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-09-20 11:05:13 +0200 |
commit | 7f0816001e085f482f8f9a34b7f8e06435907510 (patch) | |
tree | 46807f18b840e1c9816cd9b4aac001c8078d8bce /cpp/src/Slice/Python.cpp | |
parent | Fixed Ice/acm Java7 build failure (diff) | |
download | ice-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/Slice/Python.cpp')
-rw-r--r-- | cpp/src/Slice/Python.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp index 4a46afd9fdb..b42fed00c7c 100644 --- a/cpp/src/Slice/Python.cpp +++ b/cpp/src/Slice/Python.cpp @@ -356,9 +356,7 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(s.size() < 8) { - ostringstream os; - os << "invalid line '" << s << "' in '" << initPath << "'"; - throw os.str(); + throw runtime_error("invalid line '" + s + "' in '" + initPath + "'"); } string name = s.substr(7); @@ -388,16 +386,12 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub { if(state != InSubmodules) { - ostringstream os; - os << "invalid line '" << s << "' in '" << initPath << "'"; - throw os.str(); + throw runtime_error("invalid line '" + s + "' in '" + initPath + "'"); } if(s.size() < 15) { - ostringstream os; - os << "invalid line '" << s << "' in '" << initPath << "'"; - throw os.str(); + throw runtime_error("invalid line '" + s + "' in '" + initPath + "'"); } submodules.push_back(s.substr(14)); @@ -406,9 +400,7 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(state == InModules) { - ostringstream os; - os << "invalid format in '" << initPath << "'" << endl; - throw os.str(); + throw runtime_error("invalid format in '" + initPath + "'\n"); } } } @@ -807,10 +799,10 @@ Slice::Python::compile(const vector<string>& argv) consoleErr << argv[0] << ": error: " << ex.reason() << endl; return EXIT_FAILURE; } - catch(const string& err) + catch(const exception& ex) { FileTracker::instance()->cleanup(); - consoleErr << argv[0] << ": error: " << err << endl; + consoleErr << argv[0] << ": error: " << ex.what() << endl; status = EXIT_FAILURE; } } |