libzypp  11.13.5
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 
16 using std::endl;
17 
19 namespace zypp
20 {
21 
22  namespace repo
23  {
24 
26  //
27  // Repository related exceptions
28  //
30 
32  : Exception( "Repo exception" )
33  {}
34 
35  RepoException::RepoException( const std::string & msg_r )
36  : Exception( msg_r )
37  {}
38 
40  : Exception( "Repo exception" ), _info( info )
41  {}
42 
43  RepoException::RepoException( const RepoInfo & info, const std::string& msg_r )
44  : Exception( msg_r ), _info( info )
45  {}
46 
48  {}
49 
50  std::ostream & RepoException::dumpOn( std::ostream & str ) const
51  {
52  str << "[" << _info.alias() << "|" << _info.url() << "] ";
53  return Exception::dumpOn( str );
54  }
55 
57 
58 #define DEF_CTORS( CLASS, MSG ) \
59  CLASS::CLASS() : RepoException( MSG ) {} \
60  CLASS::CLASS( const std::string & msg_r ) : RepoException( msg_r ) {} \
61  CLASS::CLASS( const RepoInfo & service_r ) : RepoException( service_r, MSG ) {} \
62  CLASS::CLASS( const RepoInfo & service_r, const std::string & msg_r ) : RepoException( service_r, msg_r ) {}
63 
64  DEF_CTORS( RepoNotCachedException, "Repository is not cached" );
65  DEF_CTORS( RepoNoUrlException, "Repository has no or invalid url defined." );
66  DEF_CTORS( RepoNoAliasException, "Repository has no alias defined." );
67  DEF_CTORS( RepoInvalidAliasException, "Repository has an invalid alias." );
68  DEF_CTORS( RepoNotFoundException, "Repository not found." );
69  DEF_CTORS( RepoAlreadyExistsException, "Repository already exists." );
70  DEF_CTORS( RepoUnknownTypeException, "Repository type can't be determined." );
71  DEF_CTORS( RepoMetadataException, "Repository metadata not usable." );
72 
73 #undef DEF_CTORS
74 
76  //
77  // Service related exceptions
78  //
80 
82  : Exception( "Service exception" )
83  {}
84 
85  ServiceException::ServiceException( const std::string & msg_r )
86  : Exception( msg_r )
87  {}
88 
90  : Exception( "Service exception" ), _service( service_r )
91  {}
92 
93  ServiceException::ServiceException( const ServiceInfo & service_r, const std::string & msg_r )
94  : Exception( msg_r ), _service( service_r )
95  {}
96 
98  {}
99 
100  std::ostream & ServiceException::dumpOn( std::ostream & str ) const
101  {
102  str << "[" << _service.alias() << "|" << _service.url() << "] ";
103  return Exception::dumpOn( str );
104  }
105 
107 
108 #define DEF_CTORS( CLASS, MSG ) \
109  CLASS::CLASS() : ServiceException( MSG ) {} \
110  CLASS::CLASS( const std::string & msg_r ) : ServiceException( msg_r ) {} \
111  CLASS::CLASS( const ServiceInfo & service_r ) : ServiceException( service_r, MSG ) {} \
112  CLASS::CLASS( const ServiceInfo & service_r, const std::string & msg_r ) : ServiceException( service_r, msg_r ) {}
113 
114  DEF_CTORS( ServiceNoAliasException, "Service has no alias defined." );
115  DEF_CTORS( ServiceInvalidAliasException, "Service has an invalid alias." );
116  DEF_CTORS( ServiceAlreadyExistsException, "Service already exists." );
117  DEF_CTORS( ServiceNoUrlException, "Service has no or invalid url defined." );
118  DEF_CTORS( ServicePluginInformalException,"Service plugin has trouble providing the metadata but this should not be treated as error." );
119 
120 #undef DEF_CTORS
121 
123  } // namespace repo
126 } // namespace zypp