aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-11 15:23:22 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-11 15:23:22 +0000
commit52dc38c10a88e5c4217781cfe0600300e2afd063 (patch)
tree5b9ba5931d1d640704d5fe006ddc46031ba4ada4
parentfe5443f8db60ac06aae03d50bd41917904baa883 (diff)
downloadpaludis-52dc38c10a88e5c4217781cfe0600300e2afd063.tar.gz
paludis-52dc38c10a88e5c4217781cfe0600300e2afd063.tar.xz
Better 'all masked' error messages
-rw-r--r--paludis/dep_list.cc3
-rw-r--r--paludis/dep_list.hh15
-rw-r--r--paludis/mask_reasons.cc39
-rw-r--r--paludis/mask_reasons.hh7
-rw-r--r--paludis/package_database.cc3
-rw-r--r--paludis/package_database.hh15
-rw-r--r--src/install.cc55
7 files changed, 135 insertions, 2 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 4d3c056..71827fb 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -67,7 +67,8 @@ NoResolvableOptionError::NoResolvableOptionError(I_ i, I_ end) throw () :
}
AllMaskedError::AllMaskedError(const std::string & query) throw () :
- DepListError("Error searching for '" + query + "': no available versions")
+ DepListError("Error searching for '" + query + "': no available versions"),
+ _query(query)
{
}
diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh
index a5fff32..864c2ef 100644
--- a/paludis/dep_list.hh
+++ b/paludis/dep_list.hh
@@ -123,11 +123,26 @@ namespace paludis
*/
class AllMaskedError : public DepListError
{
+ private:
+ std::string _query;
+
public:
/**
* Constructor.
*/
AllMaskedError(const std::string & query) throw ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~AllMaskedError() throw ()
+ {
+ }
+
+ const std::string & query() const
+ {
+ return _query;
+ }
};
/**
diff --git a/paludis/mask_reasons.cc b/paludis/mask_reasons.cc
index c66ff2f..8bec168 100644
--- a/paludis/mask_reasons.cc
+++ b/paludis/mask_reasons.cc
@@ -19,4 +19,43 @@
#include <paludis/mask_reasons.hh>
+#include <paludis/util/exception.hh>
+#include <ostream>
+std::ostream &
+paludis::operator<< (std::ostream & s, const MaskReason & r)
+{
+ do
+ {
+ switch (r)
+ {
+ case mr_keyword:
+ s << "keyword";
+ continue;
+
+ case mr_user_mask:
+ s << "user mask";
+ continue;
+
+ case mr_profile_mask:
+ s << "profile mask";
+ continue;
+
+ case mr_repository_mask:
+ s << "repository mask";
+ continue;
+
+ case mr_eapi:
+ s << "EAPI";
+ continue;
+
+ case last_mr:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad MaskReason value");
+ }
+ while (false);
+
+ return s;
+}
diff --git a/paludis/mask_reasons.hh b/paludis/mask_reasons.hh
index 6c781f9..78baa9a 100644
--- a/paludis/mask_reasons.hh
+++ b/paludis/mask_reasons.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_MASK_REASONS_HH 1
#include <bitset>
+#include <iosfwd>
namespace paludis
{
@@ -42,6 +43,12 @@ namespace paludis
* A collection of reasons for why a package is masked.
*/
typedef std::bitset<last_mr> MaskReasons;
+
+ /**
+ * Stringify.
+ */
+ std::ostream &
+ operator<< (std::ostream &, const MaskReason &);
}
#endif
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index c6566cd..922b63e 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -52,7 +52,8 @@ DuplicateRepositoryError::DuplicateRepositoryError(const std::string & name) thr
}
NoSuchPackageError::NoSuchPackageError(const std::string & name) throw () :
- PackageDatabaseLookupError("Could not find '" + name + "'")
+ PackageDatabaseLookupError("Could not find '" + name + "'"),
+ _name(name)
{
}
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 630fc25..85c58df 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -185,11 +185,26 @@ namespace paludis
*/
class NoSuchPackageError : public PackageDatabaseLookupError
{
+ private:
+ std::string _name;
+
public:
/**
* Constructor.
*/
NoSuchPackageError(const std::string & name) throw ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~NoSuchPackageError() throw ()
+ {
+ }
+
+ const std::string & name() const
+ {
+ return _name;
+ }
};
/**
diff --git a/src/install.cc b/src/install.cc
index 350812c..128d805 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -206,6 +206,61 @@ do_install()
install(dep->get<p::dle_name>(), dep->get<p::dle_version>());
}
}
+ catch (const p::NoSuchPackageError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "No such package '" << e.name() << "'" << endl;
+ return 1;
+ }
+ catch (const p::AllMaskedError & e)
+ {
+ try
+ {
+ p::PackageDatabaseEntryCollection::ConstPointer p(env->package_database()->query(
+ p::PackageDepAtom::ConstPointer(new p::PackageDepAtom(e.query())),
+ p::is_uninstalled_only));
+ if (p->empty())
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "All versions of '" << e.query() << "' are masked" << endl;
+ }
+ else
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "All versions of '" << e.query() << "' are masked. Candidates are:" << endl;
+ for (p::PackageDatabaseEntryCollection::Iterator pp(p->begin()), pp_end(p->end()) ;
+ pp != pp_end ; ++pp)
+ {
+ cerr << " * " << colour(cl_package_name, *pp) << ": Masked by ";
+
+ bool need_comma(false);
+ p::MaskReasons m(env->mask_reasons(*pp));
+ for (int mm = 0 ; mm < m.size() ; ++mm)
+ if (m[mm])
+ {
+ if (need_comma)
+ cerr << ", ";
+ cerr << p::MaskReason(mm);
+ need_comma = true;
+ }
+ cerr << endl;
+ }
+ }
+ }
+ catch (...)
+ {
+ throw e;
+ }
+
+ return 1;
+ }
+
catch (const p::DepListStackTooDeepError & e)
{
cout << endl;