diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-07-30 09:51:42 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-07-30 09:51:42 +0200 |
commit | cd7bbc479f8e2f277092a9557bb486ab664deba6 (patch) | |
tree | 4c3a5ed40727d193920203d57f1b9fea09d0afd8 /apt-pkg | |
parent | 4ed3806e625a4b5c148e27dba5384f133dd77c1a (diff) |
- [ABI BREAK] add an ErrorType option to CacheSetHelper
* cmdline/apt-cache.cc:
- use Notice instead of Error in the CacheSetHelper messages
for compat reasons. Otherwise tools like sbuild blow up
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cacheset.cc | 18 | ||||
-rw-r--r-- | apt-pkg/cacheset.h | 16 | ||||
-rw-r--r-- | apt-pkg/contrib/error.cc | 16 | ||||
-rw-r--r-- | apt-pkg/contrib/error.h | 16 |
4 files changed, 56 insertions, 10 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 84021a2b7..bbfdfd4f2 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -437,21 +437,21 @@ pkgCache::VerIterator VersionSet::getInstalledVer(pkgCacheFile &Cache, pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) { if (ShowError == true) - _error->Error(_("Unable to locate package %s"), str.c_str()); + _error->Insert(ErrorType, _("Unable to locate package %s"), str.c_str()); return pkgCache::PkgIterator(Cache, 0); } /*}}}*/ // canNotFindTask - handle the case no package is found for a task /*{{{*/ PackageSet CacheSetHelper::canNotFindTask(pkgCacheFile &Cache, std::string pattern) { if (ShowError == true) - _error->Error(_("Couldn't find task '%s'"), pattern.c_str()); + _error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str()); return PackageSet(); } /*}}}*/ // canNotFindRegEx - handle the case no package is found by a regex /*{{{*/ PackageSet CacheSetHelper::canNotFindRegEx(pkgCacheFile &Cache, std::string pattern) { if (ShowError == true) - _error->Error(_("Couldn't find any package by regex '%s'"), pattern.c_str()); + _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str()); return PackageSet(); } /*}}}*/ @@ -464,7 +464,7 @@ PackageSet CacheSetHelper::canNotFindPackage(pkgCacheFile &Cache, std::string co VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Notice(_("Can't select versions from package '%s' as it purely virtual"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select versions from package '%s' as it purely virtual"), Pkg.FullName(true).c_str()); return VersionSet(); } /*}}}*/ @@ -472,7 +472,7 @@ VersionSet CacheSetHelper::canNotFindAllVer(pkgCacheFile &Cache, VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); return VersionSet(); } /*}}}*/ @@ -480,7 +480,7 @@ VersionSet CacheSetHelper::canNotFindInstCandVer(pkgCacheFile &Cache, VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); return VersionSet(); } /*}}}*/ @@ -488,7 +488,7 @@ VersionSet CacheSetHelper::canNotFindCandInstVer(pkgCacheFile &Cache, pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Error(_("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str()); return pkgCache::VerIterator(Cache, 0); } /*}}}*/ @@ -496,7 +496,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Error(_("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str()); return pkgCache::VerIterator(Cache, 0); } /*}}}*/ @@ -504,7 +504,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) - _error->Error(_("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str()); + _error->Insert(ErrorType, _("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str()); return pkgCache::VerIterator(Cache, 0); } /*}}}*/ diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index c8c3dd096..3f4f0066b 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -32,7 +32,9 @@ class CacheSetHelper { /*{{{*/ printed out. */ public: /*{{{*/ - CacheSetHelper(bool const &ShowError = true) : ShowError(ShowError) {}; + CacheSetHelper(bool const &ShowError = true, + GlobalError::MsgType ErrorType = GlobalError::ERROR) : + ShowError(ShowError), ErrorType(ErrorType) {}; virtual ~CacheSetHelper() {}; virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {}; @@ -58,9 +60,21 @@ public: /*{{{*/ bool showErrors() const { return ShowError; }; bool showErrors(bool const &newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); }; + GlobalError::MsgType errorType() const { return ErrorType; }; + GlobalError::MsgType errorType(GlobalError::MsgType const &newValue) + { + if (ErrorType == newValue) return ErrorType; + else { + GlobalError::MsgType const &oldValue = ErrorType; + ErrorType = newValue; + return oldValue; + } + }; + /*}}}*/ protected: bool ShowError; + GlobalError::MsgType ErrorType; }; /*}}}*/ class PackageSet : public std::set<pkgCache::PkgIterator> { /*{{{*/ /** \class APT::PackageSet diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index d63b06d13..e2e8d6e57 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -92,6 +92,14 @@ bool GlobalError::DebugE(const char *Function,const char *Description,...) { return InsertErrno(DEBUG, Function, Description, args); } /*}}}*/ +// GlobalError::InsertErrno - Get part of the errortype string from errno/*{{{*/ +bool GlobalError::InsertErrno(MsgType const &type, const char *Function, + const char *Description,...) { + va_list args; + va_start(args,Description); + return InsertErrno(type, Function, Description, args); +} + /*}}}*/ // GlobalError::InsertErrno - formats an error message with the errno /*{{{*/ bool GlobalError::InsertErrno(MsgType type, const char* Function, const char* Description, va_list &args) { @@ -138,6 +146,14 @@ bool GlobalError::Debug(const char *Description,...) return Insert(DEBUG, Description, args); } /*}}}*/ +// GlobalError::Insert - Add a errotype message to the list /*{{{*/ +bool GlobalError::Insert(MsgType const &type, const char *Description,...) +{ + va_list args; + va_start(args,Description); + return Insert(type, Description, args); +} + /*}}}*/ // GlobalError::Insert - Insert a new item at the end /*{{{*/ bool GlobalError::Insert(MsgType type, const char* Description, va_list &args) { diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index 4af0302c0..ae756dbc4 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -114,6 +114,15 @@ public: /*{{{*/ */ bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold; + /** \brief adds an errno message with the given type + * + * \param type of the error message + * \param Function which failed + * \param Description of the error + */ + bool InsertErrno(MsgType const &type, const char* Function, + const char* Description,...) __like_printf(4) __cold; + /** \brief add an fatal error message to the list * * Most of the stuff we consider as "error" is also "fatal" for @@ -169,6 +178,13 @@ public: /*{{{*/ */ bool Debug(const char *Description,...) __like_printf(2) __cold; + /** \brief adds an error message with the given type + * + * \param type of the error message + * \param Description of the error + */ + bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold; + /** \brief is an error in the list? * * \return \b true if an error is included in the list, \b false otherwise |