libzypp  10.5.0
RepoException.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 #include "zypp/repo/RepoException.h"
00014 #include "zypp/base/String.h"
00015 
00016 using std::endl;
00017 
00019 namespace zypp
00020 { 
00021 
00022   namespace repo
00023   { 
00024 
00026     //
00027     // Repository related exceptions
00028     //
00030 
00031     RepoException::RepoException()
00032     : Exception( "Repo exception" )
00033     {}
00034 
00035     RepoException::RepoException( const std::string & msg_r )
00036     : Exception( msg_r )
00037     {}
00038 
00039     RepoException::RepoException( const RepoInfo & info )
00040     : Exception( "Repo exception" ), _info( info )
00041     {}
00042 
00043     RepoException::RepoException( const RepoInfo & info, const std::string& msg_r )
00044     : Exception( msg_r ), _info( info )
00045     {}
00046 
00047     RepoException::~RepoException() throw()
00048     {}
00049 
00050     std::ostream & RepoException::dumpOn( std::ostream & str ) const
00051     {
00052       str << "[" << _info.alias() << "|" << _info.url() << "] ";
00053       return Exception::dumpOn( str );
00054     }
00055 
00057 
00058 #define DEF_CTORS( CLASS, MSG ) \
00059     CLASS::CLASS()                                                        : RepoException( MSG ) {} \
00060     CLASS::CLASS( const std::string & msg_r )                             : RepoException( msg_r ) {} \
00061     CLASS::CLASS( const RepoInfo & service_r )                            : RepoException( service_r, MSG ) {} \
00062     CLASS::CLASS( const RepoInfo & service_r, const std::string & msg_r ) : RepoException( service_r, msg_r ) {}
00063 
00064     DEF_CTORS( RepoNotCachedException,      "Repository is not cached" );
00065     DEF_CTORS( RepoNoUrlException,          "Repository has no or invalid url defined." );
00066     DEF_CTORS( RepoNoAliasException,        "Repository has no alias defined." );
00067     DEF_CTORS( RepoInvalidAliasException,   "Repository has an invalid alias." );
00068     DEF_CTORS( RepoNotFoundException,       "Repository not found." );
00069     DEF_CTORS( RepoAlreadyExistsException,  "Repository already exists." );
00070     DEF_CTORS( RepoUnknownTypeException,    "Repository type can't be determined." );
00071     DEF_CTORS( RepoMetadataException,       "Repository metadata not usable." );
00072 
00073 #undef DEF_CTORS
00074 
00076     //
00077     // Service related exceptions
00078     //
00080 
00081     ServiceException::ServiceException()
00082     : Exception( "Service exception" )
00083     {}
00084 
00085     ServiceException::ServiceException( const std::string & msg_r )
00086     : Exception( msg_r )
00087     {}
00088 
00089     ServiceException::ServiceException( const ServiceInfo & service_r )
00090     : Exception( "Service exception" ), _service( service_r )
00091     {}
00092 
00093     ServiceException::ServiceException( const ServiceInfo & service_r, const std::string & msg_r )
00094     : Exception( msg_r ), _service( service_r )
00095     {}
00096 
00097     ServiceException::~ServiceException() throw()
00098     {}
00099 
00100     std::ostream & ServiceException::dumpOn( std::ostream & str ) const
00101     {
00102       str << "[" << _service.alias() << "|" << _service.url() << "] ";
00103       return Exception::dumpOn( str );
00104     }
00105 
00107 
00108 #define DEF_CTORS( CLASS, MSG ) \
00109     CLASS::CLASS()                                                           : ServiceException( MSG ) {} \
00110     CLASS::CLASS( const std::string & msg_r )                                : ServiceException( msg_r ) {} \
00111     CLASS::CLASS( const ServiceInfo & service_r )                            : ServiceException( service_r, MSG ) {} \
00112     CLASS::CLASS( const ServiceInfo & service_r, const std::string & msg_r ) : ServiceException( service_r, msg_r ) {}
00113 
00114     DEF_CTORS( ServiceNoAliasException,       "Service has no alias defined." );
00115     DEF_CTORS( ServiceInvalidAliasException,  "Service has an invalid alias." );
00116     DEF_CTORS( ServiceAlreadyExistsException, "Service already exists." );
00117     DEF_CTORS( ServiceNoUrlException,         "Service has no or invalid url defined." );
00118     DEF_CTORS( ServicePluginInformalException,"Service plugin has trouble providing the metadata but this should not be treated as error." );
00119 
00120 #undef DEF_CTORS
00121 
00123   } // namespace repo
00126 } // namespace zypp