libzypp 17.37.17
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
17using std::endl;
18
20namespace zypp
21{
23 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
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
84 : Exception( "Service exception" )
85 {}
86
87 ServiceException::ServiceException( const std::string & msg_r )
88 : Exception( msg_r )
89 {}
90
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
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
#define DEF_CTORS(CLASS, MSG)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition Exception.cc:210
Exception()
Default ctor.
Definition Exception.cc:94
What is known about a repository.
Definition RepoInfo.h:72
Service data.
Definition ServiceInfo.h:37
Repository already exists and some unique attribute can't be duplicated.
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Thrown when the repo alias is found to be invalid.
thrown when it was impossible to use the raw metadata for this repo.
thrown when it was impossible to determine an alias for this repo.
thrown if the user has no permission to update(write) the caches.
thrown when it was impossible to determine one url for this repo.
The repository cache is not built yet so you can't create the repostories from the cache.
thrown when it was impossible to match a repository
thrown when it was impossible to determine this repo type.
Service already exists and some unique attribute can't be duplicated.
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Thrown when the repo alias is found to be invalid.
Service without alias was used in an operation.
Service has no or invalid url defined.
PLUGIN Service related exceptions.
Service plugin has trouble providing the metadata but this should not be treated as error.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
#define _(MSG)
Definition Gettext.h:39
Interface to gettext.