aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 14:01:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 14:01:11 +0000
commitc8ad7895d290a59432e74f60b6f7d3f2f2ac3760 (patch)
tree4b48393b26d07fdd4034f4d54cd53874ac8b8af4
parent575492dbf7cebcea504c64351e1bef32ff6d55f4 (diff)
downloadpaludis-c8ad7895d290a59432e74f60b6f7d3f2f2ac3760.tar.gz
paludis-c8ad7895d290a59432e74f60b6f7d3f2f2ac3760.tar.xz
Replace some of the InternalErrors with nicer exceptions
-rw-r--r--paludis/portage_repository.cc20
-rw-r--r--paludis/repository.cc15
-rw-r--r--paludis/repository.hh33
-rw-r--r--paludis/syncer.cc2
-rw-r--r--paludis/syncer.hh3
-rw-r--r--paludis/vdb_repository.cc12
6 files changed, 70 insertions, 15 deletions
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 16c25b5..c685c7b 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -1018,7 +1018,8 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
}
if (! _imp->root.is_directory())
- throw InternalError(PALUDIS_HERE, "todo: root not a directory");
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since root ('" + stringify(_imp->root) + "') isn't a directory");
VersionMetadata::ConstPointer metadata(0);
if (! has_version(q, v))
@@ -1030,8 +1031,8 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
metadata = m;
}
else
- throw InternalError(PALUDIS_HERE, "Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since has_version failed"); /// \todo fixme
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since has_version failed");
}
else
metadata = version_metadata(q, v);
@@ -1072,10 +1073,12 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
std::string mirror((*ff)->text().substr(9));
std::string::size_type q(mirror.find('/'));
if (std::string::npos == q)
- throw InternalError(PALUDIS_HERE, "todo"); /// \bug todo
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since SRC_URI is broken");
if (! is_mirror(mirror.substr(0, q)))
- throw InternalError(PALUDIS_HERE, "todo: not a mirror: '" +
- mirror.substr(0, q) + "'"); /// \bug todo
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since SRC_URI references unknown mirror:// '" +
+ mirror.substr(0, q) + "'");
for (std::list<std::string>::iterator
m(_imp->mirrors.find(mirror.substr(0, q))->second.begin()),
m_end(_imp->mirrors.find(mirror.substr(0, q))->second.end()) ;
@@ -1165,7 +1168,8 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
if (0 != run_command(cmd))
- throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
+ throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ + stringify(v) + "'");
}
DepAtom::Pointer
@@ -1202,5 +1206,5 @@ PortageRepository::do_sync() const
void
PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &) const
{
- throw InternalError(PALUDIS_HERE, "TODO: PortageRepository doesn't support do_uninstall");
+ throw PackageUninstallActionError("PortageRepository doesn't support do_uninstall");
}
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 5868c8e..af63c02 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -41,3 +41,18 @@ NoSuchRepositoryTypeError::NoSuchRepositoryTypeError(const std::string & format)
{
}
+PackageActionError::PackageActionError(const std::string & msg) throw () :
+ Exception(msg)
+{
+}
+
+PackageInstallActionError::PackageInstallActionError(const std::string & msg) throw () :
+ PackageActionError("Install error: " + msg)
+{
+}
+
+PackageUninstallActionError::PackageUninstallActionError(const std::string & msg) throw () :
+ PackageActionError("Uninstall error: " + msg)
+{
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 8cf5ada..fa64c9b 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -439,6 +439,39 @@ namespace paludis
NoSuchRepositoryTypeError(const std::string & format) throw ();
};
+ /**
+ * Parent class for install, uninstall errors.
+ *
+ * \ingroup Exception
+ */
+ class PackageActionError : public Exception
+ {
+ protected:
+ PackageActionError(const std::string & msg) throw ();
+ };
+
+ /**
+ * Thrown if an install fails.
+ *
+ * \ingroup Exception.
+ */
+ class PackageInstallActionError : public PackageActionError
+ {
+ public:
+ PackageInstallActionError(const std::string & msg) throw ();
+ };
+
+ /**
+ * Thrown if an uninstall fails.
+ *
+ * \ingroup Exception.
+ */
+ class PackageUninstallActionError : public PackageActionError
+ {
+ public:
+ PackageUninstallActionError(const std::string & msg) throw ();
+ };
+
class PackageDatabase;
/**
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index f27c646..28436e8 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -66,7 +66,7 @@ RsyncSyncer::sync() const
}
SyncFailedError::SyncFailedError(const std::string & local, const std::string & remote) throw () :
- Exception("sync of '" + local + "' from '" + remote + "' failed")
+ PackageActionError("sync of '" + local + "' from '" + remote + "' failed")
{
}
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index 9f534e7..4f4ef90 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -22,6 +22,7 @@
#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/exception.hh>
+#include <paludis/repository.hh>
#include <string>
using namespace paludis;
@@ -65,7 +66,7 @@ namespace paludis
* \ingroup Exception
*/
class SyncFailedError :
- public Exception
+ public PackageActionError
{
public:
/**
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 75f9a2c..ca150e1 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -468,19 +468,20 @@ VDBRepository::do_is_mirror(const std::string &) const
void
VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &) const
{
- throw InternalError(PALUDIS_HERE, "TODO: VDBRepository doesn't support do_install");
+ throw PackageInstallActionError("PortageRepository doesn't support do_install");
}
void
VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v) const
{
if (! _imp->root.is_directory())
- throw InternalError(PALUDIS_HERE, "todo: root not a directory");
+ throw PackageInstallActionError("Couldn't uninstall '" + stringify(q) + "-" +
+ stringify(v) + "' because root ('" + stringify(_imp->root) + "') is not a directory");
VersionMetadata::ConstPointer metadata(0);
if (! has_version(q, v))
- throw InternalError(PALUDIS_HERE, "Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since has_version failed"); /// \todo fixme
+ throw PackageInstallActionError("Couldn't uninstall '" + stringify(q) + "-" +
+ stringify(v) + "' because has_version failed");
else
metadata = version_metadata(q, v);
@@ -518,7 +519,8 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
if (0 != run_command(cmd))
- throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
+ throw PackageInstallActionError("Couldn't uninstall '" + stringify(q) + "-" +
+ stringify(v) + "'");
}
DepAtom::Pointer