*
*/
#include <iostream>
-//#include "zypp/base/Logger.h"
#include "zypp/repo/RepoException.h"
#include "zypp/base/String.h"
: Exception( "Repo exception" ), _info( info )
{}
- RepoException::RepoException( const RepoInfo & info,
- const std::string& 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 )
- {}
-
- RepoUnknownTypeException::RepoUnknownTypeException( const RepoInfo &info)
- : RepoException( info,
- str::form("Cannot determine type for repository %s.",info.alias().c_str()))
+ RepoException::~RepoException() throw()
{}
std::ostream & RepoException::dumpOn( std::ostream & str ) const
{
+ str << "[" << _info.alias() << "|" << _info.url() << "] ";
return Exception::dumpOn( str );
}
///////////////////////////////////////////////////////////////////
+
+#define DEF_CTORS( CLASS, MSG ) \
+ CLASS::CLASS() : RepoException( MSG ) {} \
+ CLASS::CLASS( const std::string & msg_r ) : RepoException( msg_r ) {} \
+ CLASS::CLASS( const RepoInfo & service_r ) : RepoException( service_r, MSG ) {} \
+ CLASS::CLASS( const RepoInfo & service_r, const std::string & msg_r ) : RepoException( service_r, msg_r ) {}
+
+ DEF_CTORS( RepoNotCachedException, "Repository is not cached" );
+ DEF_CTORS( RepoNoUrlException, "Repository has no or invalid url defined." );
+ DEF_CTORS( RepoNoAliasException, "Repository has no alias defined." );
+ DEF_CTORS( RepoNotFoundException, "Repository not found." );
+ DEF_CTORS( RepoAlreadyExistsException, "Repository already exists." );
+ DEF_CTORS( RepoUnknownTypeException, "Repository type can't be determined." );
+ DEF_CTORS( RepoMetadataException, "Repository metadata not usable." );
+
+#undef DEF_CTORS
+
+ ///////////////////////////////////////////////////////////////////
//
// Service related exceptions
//
*/
class RepoException : public Exception
{
- public:
- /** Default ctor */
- RepoException();
- /** Ctor */
- RepoException( const std::string & msg_r );
-
- RepoException( const RepoInfo & info );
-
- RepoException( const RepoInfo & info, const std::string & msg_r );
+ public:
+ RepoException();
+ RepoException( const std::string & msg_r );
+ RepoException( const RepoInfo & info );
+ RepoException( const RepoInfo & info, const std::string & msg_r );
+ virtual ~RepoException() throw();
- virtual ~RepoException() throw() {}
+ RepoInfo info()
+ { return _info; }
- RepoInfo info()
- { return _info; }
+ std::string alias()
+ { return info().alias(); }
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- RepoInfo _info;
+ private:
+ RepoInfo _info;
};
///////////////////////////////////////////////////////////////////
*/
class RepoNotCachedException : public RepoException
{
- public:
- RepoNotCachedException( const RepoInfo& info );
- RepoNotCachedException( const RepoInfo& info, const std::string & msg_r );
+ public:
+ RepoNotCachedException();
+ RepoNotCachedException( const std::string & msg_r );
+ RepoNotCachedException( const RepoInfo & info );
+ RepoNotCachedException( const RepoInfo & info, const std::string & msg_r );
};
/**
class RepoNoUrlException : public RepoException
{
public:
- RepoNoUrlException()
- {}
-
- RepoNoUrlException( const RepoInfo &info)
- : RepoException(info)
- {}
-
+ RepoNoUrlException();
+ RepoNoUrlException( const std::string & msg_r );
+ RepoNoUrlException( const RepoInfo & info );
+ RepoNoUrlException( const RepoInfo & info, const std::string & msg_r );
};
/**
*/
class RepoNoAliasException : public RepoException
{
-
+ public:
+ RepoNoAliasException();
+ RepoNoAliasException( const std::string & msg_r );
+ RepoNoAliasException( const RepoInfo & info );
+ RepoNoAliasException( const RepoInfo & info, const std::string & msg_r );
};
/**
*/
class RepoNotFoundException : public RepoException
{
- public:
- RepoNotFoundException( const RepoInfo &info)
- : RepoException(info)
- {}
+ public:
+ RepoNotFoundException();
+ RepoNotFoundException( const std::string & msg_r );
+ RepoNotFoundException( const RepoInfo & info );
+ RepoNotFoundException( const RepoInfo & info, const std::string & msg_r );
};
/**
*/
class RepoAlreadyExistsException : public RepoException
{
- public:
- RepoAlreadyExistsException( const RepoInfo &info,
- const std::string & msg_r )
- : RepoException(info,msg_r)
- {}
-
- RepoAlreadyExistsException( const RepoInfo &info )
- : RepoException(info)
- {}
-
- std::string alias()
- { return info().alias(); }
+ public:
+ RepoAlreadyExistsException();
+ RepoAlreadyExistsException( const std::string & msg_r );
+ RepoAlreadyExistsException( const RepoInfo & info );
+ RepoAlreadyExistsException( const RepoInfo & info, const std::string & msg_r );
};
/**
*/
class RepoUnknownTypeException : public RepoException
{
- public:
- RepoUnknownTypeException( const std::string & msg_r )
- : RepoException(msg_r)
- {}
-
- RepoUnknownTypeException( const RepoInfo &info );
-
- RepoUnknownTypeException()
- {}
-
+ public:
+ RepoUnknownTypeException();
+ RepoUnknownTypeException( const std::string & msg_r );
+ RepoUnknownTypeException( const RepoInfo & info );
+ RepoUnknownTypeException( const RepoInfo & info, const std::string & msg_r );
};
/**
*/
class RepoMetadataException : public RepoException
{
- public:
- RepoMetadataException( const RepoInfo &info)
- : RepoException(info)
- {}
-
- RepoMetadataException()
- {}
+ public:
+ RepoMetadataException();
+ RepoMetadataException( const std::string & msg_r );
+ RepoMetadataException( const RepoInfo & info );
+ RepoMetadataException( const RepoInfo & info, const std::string & msg_r );
};
//@}
ServiceInfo service()
{ return _service; }
- protected:
+ std::string alias()
+ { return service().alias(); }
+
+ protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private: