summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/Parser.cpp')
-rw-r--r--cpp/src/IceGrid/Parser.cpp55
1 files changed, 46 insertions, 9 deletions
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 0f584c4524b..ce70a4a73b7 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -189,15 +189,10 @@ Parser::addApplication(const list<string>& origArgs)
//
// Patch the application.
//
- try
+ Ice::StringSeq reasons;
+ if(!_admin->patchApplication(app.name, true, reasons))
{
- _admin->patchApplication(app.name, true);
- }
- catch(const PatchException& ex)
- {
- ostringstream s;
- s << ex << ":\n" << ex.reason;
- warning("the application was successfully added but the patch failed:\n" + s.str());
+ patchFailed(reasons);
}
}
}
@@ -373,7 +368,11 @@ Parser::patchApplication(const list<string>& origArgs)
{
vector<string>::const_iterator p = args.begin();
string name = *p++;
- _admin->patchApplication(name, opts.isSet("f") || opts.isSet("force"));
+ Ice::StringSeq reasons;
+ if(!_admin->patchApplication(name, opts.isSet("f") || opts.isSet("force"), reasons))
+ {
+ patchFailed(reasons);
+ }
}
catch(const Ice::Exception& ex)
{
@@ -1366,6 +1365,44 @@ Parser::invalidCommand(const string& s)
}
void
+Parser::patchFailed(const Ice::StringSeq& reasons)
+{
+ ostringstream os;
+ IceUtil::Output out(os);
+ out.setIndent(2);
+ out << "the patch failed on some nodes:\n";
+ for(Ice::StringSeq::const_iterator p = reasons.begin(); p != reasons.end(); ++p)
+ {
+ string reason = *p;
+ string::size_type beg = 0;
+ string::size_type end = reason.find_first_of("\n");
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out << "- " << reason.substr(beg, end - beg);
+ out.inc();
+ while(end < reason.size())
+ {
+ beg = end + 1;
+ end = reason.find_first_of("\n", beg);
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out.nl();
+ out << reason.substr(beg, end - beg);
+ }
+ out.dec();
+ if(p + 1 != reasons.end())
+ {
+ out.nl();
+ }
+ }
+ warning(os.str());
+}
+
+void
Parser::error(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))