aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 13:33:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 13:33:18 +0000
commita424f468364052a23cb23d6af0486472f5906ec7 (patch)
treeb17bfa49f2916d034f40ed83ad2baaa714e97872
parentc965f0ab6ee8c91d1e354498ce720947c5b537e1 (diff)
downloadpaludis-a424f468364052a23cb23d6af0486472f5906ec7.tar.gz
paludis-a424f468364052a23cb23d6af0486472f5906ec7.tar.xz
Throw a useful exception rather than an InternalError if sync fails. Carry on trying to sync other repos even if one sync fails.
-rw-r--r--paludis/syncer.cc7
-rw-r--r--paludis/syncer.hh16
-rw-r--r--src/sync.cc20
3 files changed, 38 insertions, 5 deletions
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 0493745..f27c646 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -62,6 +62,11 @@ RsyncSyncer::sync() const
"'" + _remote + "' '" + _local + "/'");
if (0 != run_command(cmd))
- throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
+ throw SyncFailedError(_local, _remote);
+}
+
+SyncFailedError::SyncFailedError(const std::string & local, const std::string & remote) throw () :
+ Exception("sync of '" + local + "' from '" + remote + "' failed")
+{
}
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index cb6b969..9f534e7 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -59,6 +59,22 @@ namespace paludis
NoSuchSyncerError(const std::string & format) throw ();
};
+ /**
+ * Thrown if a sync fails.
+ *
+ * \ingroup Exception
+ */
+ class SyncFailedError :
+ public Exception
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SyncFailedError(const std::string & local, const std::string & remote) throw ();
+ };
+
+
typedef VirtualConstructor<std::string, Syncer::Pointer (*) (const std::string &, const std::string &),
virtual_constructor_not_found::ThrowException<NoSuchSyncerError> > SyncerMaker;
}
diff --git a/src/sync.cc b/src/sync.cc
index a2adf5e..b779937 100644
--- a/src/sync.cc
+++ b/src/sync.cc
@@ -43,13 +43,25 @@ int do_sync()
{
std::cout << colour(cl_heading, "Sync " + p::stringify((*r)->name())) << std::endl;
- if ((*r)->sync())
+ try
{
- std::cout << "Sync " << (*r)->name() << " completed" << std::endl;
+ if ((*r)->sync())
+ {
+ std::cout << "Sync " << (*r)->name() << " completed" << std::endl;
+ }
+ else
+ {
+ std::cout << "Sync " << (*r)->name() << " skipped" << std::endl;
+ }
}
- else
+ catch (const p::SyncFailedError & e)
{
- std::cout << "Sync " << (*r)->name() << " skipped" << std::endl;
+ return_code |= 1;
+ std::cout << std::endl;
+ std::cerr << "Sync error:" << std::endl;
+ std::cerr << " * " << e.backtrace("\n * ") << e.message() << std::endl;
+ std::cerr << std::endl;
+ std::cout << "Sync " << (*r)->name() << " failed" << std::endl;
}
}