libzypp 17.35.11
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
74#undef DEF_CTORS
75
77 //
78 // Service related exceptions
79 //
81
83 : Exception( "Service exception" )
84 {}
85
87 : Exception( msg_r )
88 {}
89
91 : Exception( "Service exception" ), _service( service_r )
92 {}
93
97
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
133 } // namespace repo
136} // namespace zypp
#define DEF_CTORS(CLASS, MSG)
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Base class for Exception.
Definition Exception.h:147
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition Exception.cc:197
What is known about a repository.
Definition RepoInfo.h:72
Url url() const
Pars pro toto: The first repository url.
Definition RepoInfo.h:136
Service data.
Definition ServiceInfo.h:37
Url url() const
The service url.
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.
std::string alias() const
unique identifier for this source.
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 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.
RepoInfo _info
ServiceInfo _service
#define _(MSG)
Definition Gettext.h:39
Interface to gettext.