libzypp  17.28.0
RepoException.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
14 #include <zypp/base/String.h>
15 #include <zypp/base/Gettext.h>
16 
17 using std::endl;
18 
20 namespace zypp
21 {
22  namespace repo
24  {
25 
27  //
28  // Repository related exceptions
29  //
31 
33  : Exception( "Repo exception" )
34  {}
35 
36  RepoException::RepoException( const std::string & msg_r )
37  : Exception( msg_r )
38  {}
39 
41  : Exception( "Repo exception" ), _info( info )
42  {}
43 
44  RepoException::RepoException( const RepoInfo & info, const std::string& msg_r )
45  : Exception( msg_r ), _info( info )
46  {}
47 
49  {}
50 
51  std::ostream & RepoException::dumpOn( std::ostream & str ) const
52  {
53  str << "[" << _info.alias() << "|" << _info.url() << "] ";
54  return Exception::dumpOn( str );
55  }
56 
58 
59 #define DEF_CTORS( CLASS, MSG ) \
60  CLASS::CLASS() : RepoException( MSG ) {} \
61  CLASS::CLASS( const std::string & msg_r ) : RepoException( msg_r ) {} \
62  CLASS::CLASS( const RepoInfo & service_r ) : RepoException( service_r, MSG ) {} \
63  CLASS::CLASS( const RepoInfo & service_r, const std::string & msg_r ) : RepoException( service_r, msg_r ) {}
64 
65  DEF_CTORS( RepoNotCachedException, "Repository is not cached" );
66  DEF_CTORS( RepoNoUrlException, "Repository has no or invalid url defined." );
67  DEF_CTORS( RepoNoAliasException, "Repository has no alias defined." );
68  DEF_CTORS( RepoInvalidAliasException, "Repository has an invalid alias." );
69  DEF_CTORS( RepoNotFoundException, "Repository not found." );
70  DEF_CTORS( RepoAlreadyExistsException, "Repository already exists." );
71  DEF_CTORS( RepoUnknownTypeException, "Repository type can't be determined." );
72  DEF_CTORS( RepoMetadataException, "Repository metadata not usable." );
73 
74 #undef DEF_CTORS
75 
77  //
78  // Service related exceptions
79  //
81 
83  : Exception( "Service exception" )
84  {}
85 
86  ServiceException::ServiceException( const std::string & msg_r )
87  : Exception( msg_r )
88  {}
89 
91  : Exception( "Service exception" ), _service( service_r )
92  {}
93 
94  ServiceException::ServiceException( const ServiceInfo & service_r, const std::string & msg_r )
95  : Exception( msg_r ), _service( service_r )
96  {}
97 
99  {}
100 
101  std::ostream & ServiceException::dumpOn( std::ostream & str ) const
102  {
103  str << "[" << _service.alias() << "|" << _service.url() << "] ";
104  return Exception::dumpOn( str );
105  }
106 
108 
109 #define DEF_CTORS( CLASS, MSG ) \
110  CLASS::CLASS() : DEF_BASECLASS( MSG ) {} \
111  CLASS::CLASS( const std::string & msg_r ) : DEF_BASECLASS( msg_r ) {} \
112  CLASS::CLASS( const ServiceInfo & service_r ) : DEF_BASECLASS( service_r, MSG ) {} \
113  CLASS::CLASS( const ServiceInfo & service_r, const std::string & msg_r ) : DEF_BASECLASS( service_r, msg_r ) {}
114 
115 #define DEF_BASECLASS ServiceException
116  DEF_CTORS( ServiceNoAliasException, "Service has no alias defined." );
117  DEF_CTORS( ServiceInvalidAliasException, "Service has an invalid alias." );
118  DEF_CTORS( ServiceAlreadyExistsException, "Service already exists." );
119  DEF_CTORS( ServiceNoUrlException, "Service has no or invalid url defined." );
120 
121  // sub classes:
122  DEF_CTORS( ServicePluginException, "PLUGIN service exception." );
123 
125  // sub class: ServicePluginException
126 #undef DEF_BASECLASS
127 #define DEF_BASECLASS ServicePluginException
128  DEF_CTORS( ServicePluginInformalException, "Service plugin has trouble providing the metadata but this should not be treated as error." );
129  DEF_CTORS( ServicePluginImmutableException, _("Service plugin does not support changing an attribute.") );
130 
131 #undef DEF_CTORS
132  } // namespace repo
136 } // namespace zypp
zypp::ServiceInfo::url
Url url() const
The service url.
Definition: ServiceInfo.cc:99
zypp::repo::ServiceException::~ServiceException
virtual ~ServiceException()
Definition: RepoException.cc:98
zypp::ServiceInfo
Service data.
Definition: ServiceInfo.h:37
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
zypp::RepoInfo
What is known about a repository.
Definition: RepoInfo.h:72
zypp::repo::ServicePluginInformalException
Service plugin has trouble providing the metadata but this should not be treated as error.
Definition: RepoException.h:263
zypp::repo::RepoException::RepoException
RepoException()
Definition: RepoException.cc:32
zypp::repo::ServiceAlreadyExistsException
Service already exists and some unique attribute can't be duplicated.
Definition: RepoException.h:224
zypp::repo::RepoUnknownTypeException
thrown when it was impossible to determine this repo type.
Definition: RepoException.h:143
zypp::repo::RepoMetadataException
thrown when it was impossible to use the raw metadata for this repo.
Definition: RepoException.h:156
zypp::Exception::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: Exception.cc:141
zypp::repo::ServiceException::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: RepoException.cc:101
zypp::repo::RepoNotFoundException
thrown when it was impossible to match a repository
Definition: RepoException.h:117
zypp::repo::ServiceNoAliasException
Service without alias was used in an operation.
Definition: RepoException.h:201
zypp::repo::RepoNoAliasException
thrown when it was impossible to determine an alias for this repo.
Definition: RepoException.h:92
zypp::repo::RepoInvalidAliasException
Thrown when the repo alias is found to be invalid.
Definition: RepoException.h:104
zypp::repo::ServiceException::_service
ServiceInfo _service
Definition: RepoException.h:194
_
#define _(MSG)
Definition: Gettext.h:37
zypp::repo::RepoInfoBase::alias
std::string alias() const
unique identifier for this source.
Definition: RepoInfoBase.cc:111
zypp::repo::DEF_CTORS
DEF_CTORS(RepoNotCachedException, "Repository is not cached")
zypp::repo::RepoAlreadyExistsException
Repository already exists and some unique attribute can't be duplicated.
Definition: RepoException.h:130
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::repo::RepoException::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: RepoException.cc:51
zypp::repo::RepoNoUrlException
thrown when it was impossible to determine one url for this repo.
Definition: RepoException.h:79
zypp::repo::ServiceNoUrlException
Service has no or invalid url defined.
Definition: RepoException.h:235
zypp::repo::ServiceException::ServiceException
ServiceException()
Definition: RepoException.cc:82
zypp::repo::RepoNotCachedException
The repository cache is not built yet so you can't create the repostories from the cache.
Definition: RepoException.h:66
zypp::RepoInfo::url
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
zypp::repo::RepoException::~RepoException
virtual ~RepoException()
Definition: RepoException.cc:48
zypp::repo::ServicePluginImmutableException
Service plugin is immutable.
Definition: RepoException.h:274
zypp::repo::ServiceInvalidAliasException
Thrown when the repo alias is found to be invalid.
Definition: RepoException.h:213
str
String related utilities and Regular expression matching.
RepoException.h
zypp::repo::RepoException::_info
RepoInfo _info
Definition: RepoException.h:56
zypp::repo::ServicePluginException
PLUGIN Service related exceptions.
Definition: RepoException.h:252