better handling of exceptions here, remembering all errors.
[platform/upstream/libzypp.git] / zypp / repo / RepoException.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/parser/tagfile/RepoException.h
10  *
11 */
12 #ifndef ZYPP_REPO_REPOEXCEPTION_H
13 #define ZYPP_REPO_REPOEXCEPTION_H
14
15 #include <iosfwd>
16 #include <string>
17
18 #include "zypp/base/Exception.h"
19 #include "zypp/base/UserRequestException.h"
20 #include "zypp/RepoInfo.h"
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24   ///////////////////////////////////////////////////////////////////
25   namespace repo
26   { /////////////////////////////////////////////////////////////////
27
28     /**
29      * \short Exception for repository handling.
30      */
31     class RepoException : public Exception
32     {
33     public:
34       /** Default ctor */
35       RepoException();
36       /** Ctor */
37       RepoException( const std::string & msg_r );
38     protected:
39       virtual std::ostream & dumpOn( std::ostream & str ) const;
40     };
41     ///////////////////////////////////////////////////////////////////
42
43     /**
44      * The repository cache is not built yet
45      * so you can't create the repostories from
46      * the cache.
47      */
48     class RepoNotCachedException : public RepoException
49     {
50     public:
51       RepoNotCachedException();
52       RepoNotCachedException( const std::string & msg_r );
53     };
54     
55     /**
56      * thrown when it was impossible to
57      * determine one url for this repo.
58      */
59     class RepoNoUrlException : public RepoException
60     {
61       public:
62       RepoNoUrlException()
63       {}
64       
65       RepoNoUrlException( const RepoInfo &info)
66         : _info(info)
67       {}
68       
69       ~RepoNoUrlException() throw()
70       {}
71       
72       RepoInfo info()
73       { return _info; }
74     private:
75       RepoInfo _info;
76     };
77     
78     /**
79      * thrown when it was impossible to
80      * determine an alias for this repo.
81      */
82     class RepoNoAliasException : public RepoException
83     {
84     
85     };
86     
87     /**
88      * thrown when it was impossible to
89      * match a repository
90      */
91     class RepoNotFoundException : public RepoException
92     {
93     public:
94       RepoNotFoundException( const RepoInfo &info)
95         : _info(info)
96       {}
97       ~RepoNotFoundException() throw()
98       {}
99       
100       RepoInfo info()
101       { return _info; }
102     private:
103       RepoInfo _info;
104     };
105     
106     /**
107      * Repository already exists and some unique
108      * attribute can't be duplicated.
109      */
110     class RepoAlreadyExistsException : public RepoException
111     {
112     public:
113       ~RepoAlreadyExistsException() throw()
114       {}
115       
116       RepoAlreadyExistsException( const std::string &alias,
117                                   const std::string & msg_r )
118         : RepoException(msg_r)
119         , _alias(alias)
120       {}
121         
122       RepoAlreadyExistsException( const std::string &alias )
123         : _alias(alias)
124       {}
125       
126       std::string alias()
127       { return _alias; }
128       
129     private:
130       std::string _alias;
131     };
132     
133     /**
134      * thrown when it was impossible to
135      * determine this repo type.
136      */
137     class RepoUnknownTypeException : public RepoException
138     {
139     public:
140       RepoUnknownTypeException( const std::string & msg_r )
141         : RepoException(msg_r)
142       {}
143
144       RepoUnknownTypeException()
145       {}
146
147       ~RepoUnknownTypeException() throw()
148       {}
149     };
150
151     /**
152      * thrown when it was impossible to
153      * use the raw metadata for this repo.
154      */
155     class RepoMetadataException : public RepoException
156     {
157     public:
158       RepoMetadataException( const RepoInfo &info)
159         : _info(info)
160       {}
161
162       RepoMetadataException()
163       {}
164
165       ~RepoMetadataException() throw()
166       {}
167
168       RepoInfo info()
169       { return _info; }
170     private:
171       RepoInfo _info;
172     };
173     
174     /////////////////////////////////////////////////////////////////
175   } // namespace parser
176   ///////////////////////////////////////////////////////////////////
177   /////////////////////////////////////////////////////////////////
178 } // namespace zypp
179 ///////////////////////////////////////////////////////////////////
180 #endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H