adapt to changed ZYPP_THROW macros
[platform/upstream/libzypp.git] / zypp / media / MediaException.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaException.h
10  *
11 */
12 #ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
13 #define ZYPP_MEDIA_MEDIAEXCEPTION_H
14
15 #include <iosfwd>
16
17 #include <string>
18
19 #include "zypp/base/Exception.h"
20 #include "zypp/Pathname.h"
21 #include "zypp/Url.h"
22
23 ///////////////////////////////////////////////////////////////////
24 namespace zypp
25 { /////////////////////////////////////////////////////////////////
26   namespace media {
27     ///////////////////////////////////////////////////////////////
28     //
29     //  CLASS NAME : MediaException
30     /** Just inherits Exception to separate media exceptions
31      *
32      **/
33     class MediaException : public Exception
34     {
35     public:
36       /** Ctor taking message.
37        * Use \ref ZYPP_THROW to throw exceptions.
38       */
39       MediaException()
40       : Exception( "Media Exception" )
41       {}
42       /** Ctor taking message.
43        * Use \ref ZYPP_THROW to throw exceptions.
44       */
45       MediaException( const std::string & msg_r )
46       : Exception( msg_r )
47       {}
48       /** Dtor. */
49       virtual ~MediaException() throw() {};
50     };
51
52     class MediaMountException : public MediaException
53     {
54     public:
55       /** Ctor taking message.
56        * Use \ref ZYPP_THROW to throw exceptions.
57       */
58       MediaMountException( const std::string & error_r,
59                            const std::string & source_r,
60                            const std::string & target_r )
61       : MediaException()
62       , _error(error_r)
63       , _source(source_r)
64       , _target(target_r)
65       {}
66       /** Dtor. */
67       virtual ~MediaMountException() throw() {};
68     protected:
69       virtual std::ostream & dumpOn( std::ostream & str ) const;
70     private:
71       std::string _error;
72       std::string _source;
73       std::string _target;
74     };
75
76     class MediaUnmountException : public MediaException
77     {
78     public:
79       /** Ctor taking message.
80        * Use \ref ZYPP_THROW to throw exceptions.
81       */
82       MediaUnmountException( const std::string & error_r,
83                              const std::string & path_r )
84       : MediaException()
85       , _error(error_r)
86       , _path(path_r)
87       {}
88       /** Dtor. */
89       virtual ~MediaUnmountException() throw() {};
90     protected:
91       virtual std::ostream & dumpOn( std::ostream & str ) const;
92     private:
93       std::string _error;
94       std::string _path;
95     };
96
97     class MediaBadFilenameException : public MediaException
98     {
99     public:
100       MediaBadFilenameException(const std::string & filename_r)
101       : MediaException()
102       , _filename(filename_r)
103       {}
104       virtual ~MediaBadFilenameException() throw() {};
105       std::string filename() const { return _filename; }
106     protected:
107       virtual std::ostream & dumpOn( std::ostream & str ) const;
108     private:
109       std::string _filename;
110     };
111
112     class MediaNotOpenException : public MediaException
113     {
114     public:
115       MediaNotOpenException()
116       : MediaException()
117       {}
118       virtual ~MediaNotOpenException() throw() {};
119     protected:
120       virtual std::ostream & dumpOn( std::ostream & str ) const;
121     private:
122     };
123
124     class MediaFileNotFoundException : public MediaException
125     {
126     public:
127       MediaFileNotFoundException(const Url & url_r,
128                                  const Pathname & filename_r)
129       : MediaException()
130       , _url(url_r.toString())
131       , _filename(filename_r.asString())
132       {}
133       virtual ~MediaFileNotFoundException() throw() {};
134     protected:
135       virtual std::ostream & dumpOn( std::ostream & str ) const;
136     private:
137       std::string _url;
138       std::string _filename;
139     };
140
141     class MediaWriteException : public MediaException
142     {
143     public:
144       MediaWriteException(const Pathname & filename_r)
145       : MediaException()
146       , _filename(filename_r.asString())
147       {}
148       virtual ~MediaWriteException() throw() {};
149     protected:
150       virtual std::ostream & dumpOn( std::ostream & str ) const;
151     private:
152       std::string _filename;
153     };
154
155     class MediaNotAttachedException : public MediaException
156     {
157     public:
158       MediaNotAttachedException(const Url & url_r)
159       : MediaException()
160       , _url(url_r.toString())
161       {}
162       virtual ~MediaNotAttachedException() throw() {};
163     protected:
164       virtual std::ostream & dumpOn( std::ostream & str ) const;
165     private:
166       std::string _url;
167     };
168
169     class MediaSystemException : public MediaException
170     {
171     public:
172       MediaSystemException(const Url & url_r,
173                            const std::string & message_r)
174       : MediaException()
175       , _url(url_r.toString())
176       , _message(message_r)
177       {}
178       virtual ~MediaSystemException() throw() {};
179     protected:
180       virtual std::ostream & dumpOn( std::ostream & str ) const;
181     private:
182       std::string _url;
183       std::string _message;
184     };
185
186     class MediaNotAFileException : public MediaException
187     {
188     public:
189       MediaNotAFileException(const Url & url_r,
190                              const Pathname & path_r)
191       : MediaException()
192       , _url(url_r.toString())
193       , _path(path_r.asString())
194       {}
195       virtual ~MediaNotAFileException() throw() {};
196     protected:
197       virtual std::ostream & dumpOn( std::ostream & str ) const;
198     private:
199       std::string _url;
200       std::string _path;
201     };
202
203     class MediaNotADirException : public MediaException
204     {
205     public:
206       MediaNotADirException(const Url & url_r,
207                             const Pathname & path_r)
208       : MediaException()
209       , _url(url_r.toString())
210       , _path(path_r.asString())
211       {}
212       virtual ~MediaNotADirException() throw() {};
213     protected:
214       virtual std::ostream & dumpOn( std::ostream & str ) const;
215     private:
216       std::string _url;
217       std::string _path;
218     };
219
220     class MediaBadUrlException : public MediaException
221     {
222     public:
223       MediaBadUrlException(const Url & url_r)
224       : MediaException()
225       , _url(url_r.toString())
226       {}
227       virtual ~MediaBadUrlException() throw() {};
228     protected:
229       virtual std::ostream & dumpOn( std::ostream & str ) const;
230     private:
231       std::string _url;
232     };
233
234
235
236   /////////////////////////////////////////////////////////////////
237   } // namespace media
238 } // namespace zypp
239 ///////////////////////////////////////////////////////////////////
240 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H