move RepoInfo to universal RepoException. This can enable more verbose output for...
authorJosef Reidinger <jreidinger@suse.cz>
Tue, 8 Apr 2008 11:15:12 +0000 (11:15 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Tue, 8 Apr 2008 11:15:12 +0000 (11:15 +0000)
zypp/RepoManager.cc
zypp/repo/RepoException.cc
zypp/repo/RepoException.h
zypp/repo/RepoProvideFile.cc

index 9f8cbab..d020a95 100644 (file)
@@ -920,7 +920,7 @@ namespace zypp
     Pathname solvfile = (_pimpl->options.repoCachePath / alias).extend(".solv");
 
     if ( ! PathInfo(solvfile).isExist() )
-      ZYPP_THROW(RepoNotCachedException());
+      ZYPP_THROW(RepoNotCachedException(info));
 
     try
     {
@@ -1013,7 +1013,7 @@ namespace zypp
           ++it )
     {
       if ( info.alias() == (*it).alias() )
-        ZYPP_THROW(RepoAlreadyExistsException(info.alias()));
+        ZYPP_THROW(RepoAlreadyExistsException(info));
     }
 
     RepoInfo tosave = info;
@@ -1071,7 +1071,7 @@ namespace zypp
         if ( (*it).alias() == (*kit).alias() )
         {
           ERR << "To be added repo " << (*it).alias() << " conflicts with existing repo " << (*kit).alias() << endl;
-          ZYPP_THROW(RepoAlreadyExistsException((*it).alias()));
+          ZYPP_THROW(RepoAlreadyExistsException(*it));
         }
       }
     }
@@ -1205,7 +1205,7 @@ namespace zypp
             ++it )
       {
         if ( newinfo.alias() == (*it).alias() )
-          ZYPP_THROW(RepoAlreadyExistsException(newinfo.alias()));
+          ZYPP_THROW(RepoAlreadyExistsException(newinfo));
       }
     }
 
index 9e5d638..5eb845b 100644 (file)
@@ -30,12 +30,22 @@ namespace zypp
     : Exception( msg_r )
     {}
 
-    RepoNotCachedException::RepoNotCachedException()
-    : RepoException( "Repository not Cached" )
+    RepoException::RepoException( const RepoInfo & info )
+    : Exception( "Repo exception" ), _info( info )
     {}
 
-    RepoNotCachedException::RepoNotCachedException( const std::string & msg_r )
-    : RepoException( msg_r )
+    RepoException::RepoException( const RepoInfo & info,
+        const std::string& msg_r )
+    : Exception( msg_r ), _info( info )
+    {}
+
+    RepoNotCachedException::RepoNotCachedException( const RepoInfo& info )
+    : RepoException( info, "Repository not Cached" )
+    {}
+
+    RepoNotCachedException::RepoNotCachedException(  const RepoInfo& info, 
+        const std::string & msg_r )
+    : RepoException( info, msg_r )
     {}
 
 
index d99c1ba..21f0574 100644 (file)
@@ -35,8 +35,21 @@ namespace zypp
       RepoException();
       /** Ctor */
       RepoException( const std::string & msg_r );
+
+      RepoException( const RepoInfo & info );
+
+      RepoException( const RepoInfo & info, const std::string & msg_r );
+
+      virtual ~RepoException() throw() {}
+      
+      RepoInfo info()
+      { return _info; }
+
     protected:
       virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+    private:
+      RepoInfo _info;
     };
     ///////////////////////////////////////////////////////////////////
 
@@ -48,8 +61,8 @@ namespace zypp
     class RepoNotCachedException : public RepoException
     {
     public:
-      RepoNotCachedException();
-      RepoNotCachedException( const std::string & msg_r );
+      RepoNotCachedException( const RepoInfo& info );
+      RepoNotCachedException( const RepoInfo& info, const std::string & msg_r );
     };
     
     /**
@@ -63,16 +76,9 @@ namespace zypp
       {}
       
       RepoNoUrlException( const RepoInfo &info)
-        : _info(info)
-      {}
+        : RepoException(info)
+        {}
       
-      ~RepoNoUrlException() throw()
-      {}
-      
-      RepoInfo info()
-      { return _info; }
-    private:
-      RepoInfo _info;
     };
     
     /**
@@ -92,15 +98,8 @@ namespace zypp
     {
     public:
       RepoNotFoundException( const RepoInfo &info)
-        : _info(info)
-      {}
-      ~RepoNotFoundException() throw()
+        : RepoException(info)
       {}
-      
-      RepoInfo info()
-      { return _info; }
-    private:
-      RepoInfo _info;
     };
     
     /**
@@ -110,24 +109,17 @@ namespace zypp
     class RepoAlreadyExistsException : public RepoException
     {
     public:
-      ~RepoAlreadyExistsException() throw()
-      {}
-      
-      RepoAlreadyExistsException( const std::string &alias,
+      RepoAlreadyExistsException( const RepoInfo &info,
                                   const std::string & msg_r )
-        : RepoException(msg_r)
-        , _alias(alias)
+        : RepoException(info,msg_r)
       {}
         
-      RepoAlreadyExistsException( const std::string &alias )
-        : _alias(alias)
+      RepoAlreadyExistsException( const RepoInfo &info )
+        : RepoException(info)
       {}
       
       std::string alias()
-      { return _alias; }
-      
-    private:
-      std::string _alias;
+      { return info().alias(); }
     };
     
     /**
@@ -144,8 +136,6 @@ namespace zypp
       RepoUnknownTypeException()
       {}
 
-      ~RepoUnknownTypeException() throw()
-      {}
     };
 
     /**
@@ -156,19 +146,11 @@ namespace zypp
     {
     public:
       RepoMetadataException( const RepoInfo &info)
-        : _info(info)
+        : RepoException(info)
       {}
 
       RepoMetadataException()
       {}
-
-      ~RepoMetadataException() throw()
-      {}
-
-      RepoInfo info()
-      { return _info; }
-    private:
-      RepoInfo _info;
     };
     
     /////////////////////////////////////////////////////////////////
index ecb3539..7439a5d 100644 (file)
@@ -212,7 +212,8 @@ namespace zypp
 
       Url url;
 
-      RepoException repo_excpt(str::form(_("Can't provide file '%s' from repository '%s'"),
+      RepoException repo_excpt(repo_r, 
+                            str::form(_("Can't provide file '%s' from repository '%s'"),
                                loc_r.filename().c_str(),
                                repo_r.alias().c_str() ) );