From 93ad577d737b265a4fb921337ea7765a6dd2a27c Mon Sep 17 00:00:00 2001 From: Ciaran McCreesh Date: Sat, 11 Dec 2010 16:52:02 +0000 Subject: Better error for uninstall multiple versions --- src/clients/cave/cmd_uninstall.cc | 2 +- src/clients/cave/exceptions.cc | 7 +++++++ src/clients/cave/exceptions.hh | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/clients/cave/cmd_uninstall.cc b/src/clients/cave/cmd_uninstall.cc index 78a000309..d7829fc93 100644 --- a/src/clients/cave/cmd_uninstall.cc +++ b/src/clients/cave/cmd_uninstall.cc @@ -146,7 +146,7 @@ UninstallCommand::run( if (ids->empty()) nothing_matching_error(env.get(), *p, filter::SupportsAction()); else if ((! cmdline.a_all_versions.specified()) && has_multiple_versions(ids)) - throw BeMoreSpecific(spec, ids); + throw BeMoreSpecific(spec, ids, "Consider using '--" + cmdline.a_all_versions.long_name() + "'"); else { for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ; diff --git a/src/clients/cave/exceptions.cc b/src/clients/cave/exceptions.cc index c207b2ef4..b606320c5 100644 --- a/src/clients/cave/exceptions.cc +++ b/src/clients/cave/exceptions.cc @@ -57,6 +57,13 @@ BeMoreSpecific::BeMoreSpecific(const PackageDepSpec & spec, const std::shared_pt { } +BeMoreSpecific::BeMoreSpecific(const PackageDepSpec & spec, const std::shared_ptr & s, + const std::string & extra_message) throw () : + Exception("Found multiple suitable IDs matching '" + stringify(spec) + "': { '" + join(indirect_iterator(s->begin()), + indirect_iterator(s->end()), "', '") + "' }. " + extra_message) +{ +} + BadIDForCommand::BadIDForCommand(const PackageDepSpec & spec, const std::shared_ptr & s, const std::string & r) throw () : Exception("Spec '" + stringify(spec) + "' resolves to ID '" + stringify(*s) + "', which " + r) diff --git a/src/clients/cave/exceptions.hh b/src/clients/cave/exceptions.hh index 7e42f39e1..233c39329 100644 --- a/src/clients/cave/exceptions.hh +++ b/src/clients/cave/exceptions.hh @@ -53,6 +53,8 @@ namespace paludis { public: BeMoreSpecific(const PackageDepSpec &, const std::shared_ptr &) throw (); + BeMoreSpecific(const PackageDepSpec &, const std::shared_ptr &, + const std::string & extra_message) throw (); }; class PALUDIS_VISIBLE BadIDForCommand : -- cgit v1.2.3