libzypp: zypp/repo/RepoException.cc Source File

libzypp 17.38.11

RepoException.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <zypp/repo/RepoException.h>
14#include <zypp-core/base/String.h>
15#include <zypp-core/base/Gettext.h>
16
17using std::endl;
18
20namespace zypp
21{
23 namespace repo
24 {
25
27 //
28 // Repository related exceptions
29 //
31
32 RepoException::RepoException()
33 : Exception( "Repo exception" )
34 {}
35
36 RepoException::RepoException( const std::string & msg_r )
37 : Exception( msg_r )
38 {}
39
40 RepoException::RepoException( const RepoInfo & info )
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
48 RepoException::~RepoException() throw()
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 DEF_CTORS( RepoNoPermissionException, _("No permission to write repository cache.") );
74
75#undef DEF_CTORS
76
78 //
79 // Service related exceptions
80 //
82
83 ServiceException::ServiceException()
84 : Exception( "Service exception" )
85 {}
86
87 ServiceException::ServiceException( const std::string & msg_r )
88 : Exception( msg_r )
89 {}
90
91 ServiceException::ServiceException( const ServiceInfo & service_r )
92 : Exception( "Service exception" ), _service( service_r )
93 {}
94
95 ServiceException::ServiceException( const ServiceInfo & service_r, const std::string & msg_r )
96 : Exception( msg_r ), _service( service_r )
97 {}
98
99 ServiceException::~ServiceException() throw()
100 {}
101
102 std::ostream & ServiceException::dumpOn( std::ostream & str ) const
103 {
104 str << "[" << _service.alias() << "|" << _service.url() << "] ";
105 return Exception::dumpOn( str );
106 }
107
109
110#define DEF_CTORS( CLASS, MSG ) \
111 CLASS::CLASS() : DEF_BASECLASS( MSG ) {} \
112 CLASS::CLASS( const std::string & msg_r ) : DEF_BASECLASS( msg_r ) {} \
113 CLASS::CLASS( const ServiceInfo & service_r ) : DEF_BASECLASS( service_r, MSG ) {} \
114 CLASS::CLASS( const ServiceInfo & service_r, const std::string & msg_r ) : DEF_BASECLASS( service_r, msg_r ) {}
115
116#define DEF_BASECLASS ServiceException
117 DEF_CTORS( ServiceNoAliasException, "Service has no alias defined." );
118 DEF_CTORS( ServiceInvalidAliasException, "Service has an invalid alias." );
119 DEF_CTORS( ServiceAlreadyExistsException, "Service already exists." );
120 DEF_CTORS( ServiceNoUrlException, "Service has no or invalid url defined." );
121
122 // sub classes:
123 DEF_CTORS( ServicePluginException, "PLUGIN service exception." );
124
126 // sub class: ServicePluginException
127#undef DEF_BASECLASS
128#define DEF_BASECLASS ServicePluginException
129 DEF_CTORS( ServicePluginInformalException, "Service plugin has trouble providing the metadata but this should not be treated as error." );
130 DEF_CTORS( ServicePluginImmutableException, _("Service plugin does not support changing an attribute.") );
131
132#undef DEF_CTORS
134 } // namespace repo
137} // namespace zypp
Gettext.h
_
#define _(MSG)
Definition Gettext.h:39
DEF_CTORS
#define DEF_CTORS(CLASS, MSG)
Definition RepoException.cc:59
RepoException.h
String.h
zypp::Exception::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition Exception.cc:210
zypp::Exception::Exception
Exception()
Default ctor.
Definition Exception.cc:94
zypp::RepoInfo
What is known about a repository.
Definition RepoInfo.h:72
zypp::ServiceInfo
Service data.
Definition ServiceInfo.h:37
zypp::repo::RepoAlreadyExistsException
Repository already exists and some unique attribute can't be duplicated.
Definition RepoException.h:130
zypp::repo::RepoException::info
RepoInfo info()
Definition RepoException.h:46
zypp::repo::RepoException::RepoException
RepoException()
Definition RepoException.cc:32
zypp::repo::RepoException::_info
RepoInfo _info
Definition RepoException.h:56
zypp::repo::RepoException::~RepoException
~RepoException() override
Definition RepoException.cc:48
zypp::repo::RepoException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition RepoException.cc:51
zypp::repo::RepoInvalidAliasException
Thrown when the repo alias is found to be invalid.
Definition RepoException.h:104
zypp::repo::RepoMetadataException
thrown when it was impossible to use the raw metadata for this repo.
Definition RepoException.h:156
zypp::repo::RepoNoAliasException
thrown when it was impossible to determine an alias for this repo.
Definition RepoException.h:92
zypp::repo::RepoNoPermissionException
thrown if the user has no permission to update(write) the caches.
Definition RepoException.h:168
zypp::repo::RepoNoUrlException
thrown when it was impossible to determine one url for this repo.
Definition RepoException.h:79
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::repo::RepoNotFoundException
thrown when it was impossible to match a repository
Definition RepoException.h:117
zypp::repo::RepoUnknownTypeException
thrown when it was impossible to determine this repo type.
Definition RepoException.h:143
zypp::repo::ServiceAlreadyExistsException
Service already exists and some unique attribute can't be duplicated.
Definition RepoException.h:237
zypp::repo::ServiceException::_service
ServiceInfo _service
Definition RepoException.h:207
zypp::repo::ServiceException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition RepoException.cc:102
zypp::repo::ServiceException::~ServiceException
~ServiceException() override
Definition RepoException.cc:99
zypp::repo::ServiceException::ServiceException
ServiceException()
Definition RepoException.cc:83
zypp::repo::ServiceInvalidAliasException
Thrown when the repo alias is found to be invalid.
Definition RepoException.h:226
zypp::repo::ServiceNoAliasException
Service without alias was used in an operation.
Definition RepoException.h:214
zypp::repo::ServiceNoUrlException
Service has no or invalid url defined.
Definition RepoException.h:248
zypp::repo::ServicePluginException
PLUGIN Service related exceptions.
Definition RepoException.h:265
zypp::repo::ServicePluginImmutableException
Service plugin is immutable.
Definition RepoException.h:287
zypp::repo::ServicePluginInformalException
Service plugin has trouble providing the metadata but this should not be treated as error.
Definition RepoException.h:276
str
String related utilities and Regular expression matching.
zypp::repo
Definition DeltaCandidates.cc:30
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2