libzypp  17.3.1
MediaException.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
13 #define ZYPP_MEDIA_MEDIAEXCEPTION_H
14 
15 #include <iosfwd>
16 
17 #include <string>
18 #include <vector>
19 
20 #include "zypp/base/Exception.h"
21 #include "zypp/Pathname.h"
22 #include "zypp/Url.h"
23 
25 namespace zypp
26 {
27  namespace media {
29  //
30  // CLASS NAME : MediaException
34  class MediaException : public Exception
35  {
36  public:
40  MediaException() : Exception( "Media Exception" )
41  {}
45  MediaException( const std::string & msg_r )
46  : Exception( msg_r )
47  {}
48 
50  virtual ~MediaException() throw() {};
51  };
52 
54  {
55  public:
57  : MediaException( "Media Mount Exception" )
58  {}
59 
63  MediaMountException( const std::string & error_r,
64  const std::string & source_r,
65  const std::string & target_r,
66  const std::string & cmdout_r="")
67  : MediaException()
68  , _error(error_r)
69  , _source(source_r)
70  , _target(target_r)
71  , _cmdout(cmdout_r)
72  {}
74  virtual ~MediaMountException() throw() {};
75 
76  const std::string & mountError() const
77  { return _error; }
78  const std::string & mountSource() const
79  { return _source; }
80  const std::string & mountTarget() const
81  { return _target; }
82  const std::string & mountOutput() const
83  { return _cmdout; }
84 
85  protected:
86  virtual std::ostream & dumpOn( std::ostream & str ) const;
87  private:
88  std::string _error;
89  std::string _source;
90  std::string _target;
91  std::string _cmdout;
92  };
93 
95  {
96  public:
100  MediaUnmountException( const std::string & error_r,
101  const std::string & path_r )
102  : MediaException()
103  , _error(error_r)
104  , _path(path_r)
105  {}
107  virtual ~MediaUnmountException() throw() {};
108  protected:
109  virtual std::ostream & dumpOn( std::ostream & str ) const;
110  private:
111  std::string _error;
112  std::string _path;
113  };
114 
116  {
117  public:
118  MediaBadFilenameException(const std::string & filename_r)
119  : MediaException()
120  , _filename(filename_r)
121  {}
122  virtual ~MediaBadFilenameException() throw() {};
123  std::string filename() const { return _filename; }
124  protected:
125  virtual std::ostream & dumpOn( std::ostream & str ) const;
126  private:
127  std::string _filename;
128  };
129 
131  {
132  public:
133  MediaNotOpenException(const std::string & action_r)
134  : MediaException()
135  , _action(action_r)
136  {}
137  virtual ~MediaNotOpenException() throw() {};
138  protected:
139  virtual std::ostream & dumpOn( std::ostream & str ) const;
140  private:
141  std::string _action;
142  };
143 
145  {
146  public:
148  const Pathname & filename_r)
149  : MediaException()
150  , _url(url_r.asString())
151  , _filename(filename_r.asString())
152  {}
153  virtual ~MediaFileNotFoundException() throw() {};
154  protected:
155  virtual std::ostream & dumpOn( std::ostream & str ) const;
156  private:
157  std::string _url;
158  std::string _filename;
159  };
160 
162  {
163  public:
164  MediaWriteException(const Pathname & filename_r)
165  : MediaException()
166  , _filename(filename_r.asString())
167  {}
168  virtual ~MediaWriteException() throw() {};
169  protected:
170  virtual std::ostream & dumpOn( std::ostream & str ) const;
171  private:
172  std::string _filename;
173  };
174 
176  {
177  public:
179  : MediaException()
180  , _url(url_r.asString())
181  {}
182  virtual ~MediaNotAttachedException() throw() {};
183  protected:
184  virtual std::ostream & dumpOn( std::ostream & str ) const;
185  private:
186  std::string _url;
187  };
188 
190  {
191  public:
193  : MediaException()
194  , _url(url_r.asString())
195  {}
196  virtual ~MediaBadAttachPointException() throw() {};
197  protected:
198  virtual std::ostream & dumpOn( std::ostream & str ) const;
199  private:
200  std::string _url;
201  };
202 
204  {
205  public:
207  : MediaException()
208  , _url(url_r.asString())
209  {}
210  virtual ~MediaCurlInitException() throw() {};
211  protected:
212  virtual std::ostream & dumpOn( std::ostream & str ) const;
213  private:
214  std::string _url;
215  };
216 
218  {
219  public:
220  MediaSystemException(const Url & url_r,
221  const std::string & message_r)
222  : MediaException()
223  , _url(url_r.asString())
224  , _message(message_r)
225  {}
226  virtual ~MediaSystemException() throw() {};
227  protected:
228  virtual std::ostream & dumpOn( std::ostream & str ) const;
229  private:
230  std::string _url;
231  std::string _message;
232  };
233 
235  {
236  public:
238  const Pathname & path_r)
239  : MediaException()
240  , _url(url_r.asString())
241  , _path(path_r.asString())
242  {}
243  virtual ~MediaNotAFileException() throw() {};
244  protected:
245  virtual std::ostream & dumpOn( std::ostream & str ) const;
246  private:
247  std::string _url;
248  std::string _path;
249  };
250 
252  {
253  public:
254  MediaNotADirException(const Url & url_r,
255  const Pathname & path_r)
256  : MediaException()
257  , _url(url_r.asString())
258  , _path(path_r.asString())
259  {}
260  virtual ~MediaNotADirException() throw() {};
261  protected:
262  virtual std::ostream & dumpOn( std::ostream & str ) const;
263  private:
264  std::string _url;
265  std::string _path;
266  };
267 
269  {
270  public:
271  MediaBadUrlException(const Url & url_r,
272  const std::string &msg_r = std::string())
273  : MediaException()
274  , _url(url_r.asString())
275  , _msg(msg_r)
276  {}
277  virtual ~MediaBadUrlException() throw() {};
278  protected:
279  virtual std::ostream & dumpOn( std::ostream & str ) const;
280  std::string _url;
281  std::string _msg;
282  };
283 
285  {
286  public:
288  : MediaBadUrlException(url_r)
289  {}
290  virtual ~MediaBadUrlEmptyHostException() throw() {};
291  protected:
292  virtual std::ostream & dumpOn( std::ostream & str ) const;
293  };
294 
296  {
297  public:
299  : MediaBadUrlException(url_r)
300  {}
302  protected:
303  virtual std::ostream & dumpOn( std::ostream & str ) const;
304  };
305 
307  {
308  public:
310  : MediaBadUrlException(url_r)
311  {}
313  protected:
314  virtual std::ostream & dumpOn( std::ostream & str ) const;
315  };
316 
318  {
319  public:
321  : MediaBadUrlException(url_r)
322  {}
324  protected:
325  virtual std::ostream & dumpOn( std::ostream & str ) const;
326  };
327 
329  {
330  public:
332  : MediaException()
333  , _url(url_r.asString())
334  {}
335  virtual ~MediaNotSupportedException() throw() {};
336  protected:
337  virtual std::ostream & dumpOn( std::ostream & str ) const;
338  std::string _url;
339  };
340 
342  {
343  public:
344  MediaCurlException(const Url & url_r,
345  const std::string & err_r,
346  const std::string & msg_r)
347  : MediaException()
348  , _url(url_r.asString())
349  , _err(err_r)
350  , _msg(msg_r)
351  {}
352  virtual ~MediaCurlException() throw() {};
353  std::string errstr() const { return _err; }
354  protected:
355  virtual std::ostream & dumpOn( std::ostream & str ) const;
356  std::string _url;
357  std::string _err;
358  std::string _msg;
359  };
360 
362  {
363  public:
364  MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
365  : MediaException()
366  , _url(url_r.asString())
367  , _msg(msg_r)
368  {}
369  virtual ~MediaCurlSetOptException() throw() {};
370  protected:
371  virtual std::ostream & dumpOn( std::ostream & str ) const;
372  std::string _url;
373  std::string _msg;
374  };
375 
377  {
378  public:
380  : MediaException()
381  , _url(url_r.asString())
382  {}
383  virtual ~MediaNotDesiredException() throw() {};
384  protected:
385  virtual std::ostream & dumpOn( std::ostream & str ) const;
386  private:
387  std::string _url;
388  };
389 
391  {
392  public:
396  MediaIsSharedException(const std::string &name)
397  : MediaException()
398  , _name(name)
399  {}
400  virtual ~MediaIsSharedException() throw() {};
401  protected:
402  virtual std::ostream & dumpOn( std::ostream & str ) const;
403  private:
404  std::string _name;
405  };
406 
408  {
409  public:
411  : MediaException("Can't eject any media")
412  , _name("")
413  {}
414 
415  MediaNotEjectedException(const std::string &name)
416  : MediaException("Can't eject media")
417  , _name(name)
418  {}
419  virtual ~MediaNotEjectedException() throw() {};
420  protected:
421  virtual std::ostream & dumpOn( std::ostream & str ) const;
422  private:
423  std::string _name;
424  };
425 
427  {
428  public:
430  : MediaException("Unauthorized media access")
431  , _url("")
432  , _err("")
433  , _hint("")
434  {}
435 
437  const std::string &msg_r,
438  const std::string &err_r,
439  const std::string &hint_r)
440  : MediaException(msg_r)
441  , _url(url_r)
442  , _err(err_r)
443  , _hint(hint_r)
444  {}
445 
446  virtual ~MediaUnauthorizedException() throw() {};
447 
448  const Url & url() const { return _url; }
449  const std::string & err() const { return _err; }
451  const std::string & hint() const { return _hint; }
452 
453  protected:
454  virtual std::ostream & dumpOn( std::ostream & str ) const;
455  private:
457  std::string _err;
458  std::string _hint;
459  };
460 
462  {
463  public:
464  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
466  , _url(url_r.asString()), _msg(msg)
467  {}
468  virtual ~MediaForbiddenException() throw() {};
469  protected:
470  virtual std::ostream & dumpOn( std::ostream & str ) const;
471  std::string _url;
472  std::string _msg;
473  };
474 
476  {
477  public:
478  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
480  , _url(url_r.asString()), _msg(msg)
481  {}
482  virtual ~MediaTimeoutException() throw() {};
483  protected:
484  virtual std::ostream & dumpOn( std::ostream & str ) const;
485  std::string _url;
486  std::string _msg;
487  };
488 
491  {
492  public:
493  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
495  , _url(url_r.asString()), _msg(msg)
496  {}
497  virtual ~MediaTemporaryProblemException() throw() {};
498  protected:
499  virtual std::ostream & dumpOn( std::ostream & str ) const;
500  std::string _url;
501  std::string _msg;
502  };
503 
505  {
506  public:
507  MediaBadCAException(const Url & url_r, const std::string & msg = "")
509  , _url(url_r.asString()), _msg(msg)
510  {}
511  virtual ~MediaBadCAException() throw() {};
512  protected:
513  virtual std::ostream & dumpOn( std::ostream & str ) const;
514  std::string _url;
515  std::string _msg;
516  };
517 
519  } // namespace media
520 } // namespace zypp
522 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaMountException(const std::string &error_r, const std::string &source_r, const std::string &target_r, const std::string &cmdout_r="")
Ctor taking message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
const std::string & mountError() const
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaTemporaryProblemException(const Url &url_r, const std::string &msg="")
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
const std::string & mountTarget() const
const std::string & mountSource() const
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaNotAFileException(const Url &url_r, const Pathname &path_r)
MediaUnauthorizedException(const Url &url_r, const std::string &msg_r, const std::string &err_r, const std::string &hint_r)
MediaCurlSetOptException(const Url &url_r, const std::string &msg_r)
String related utilities and Regular expression matching.
const std::string & err() const
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaForbiddenException(const Url &url_r, const std::string &msg="")
MediaException()
Ctor taking message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
const std::string & hint() const
comma separated list of available authentication types
std::string asString() const
Error message provided by dumpOn as string.
Definition: Exception.cc:75
Just inherits Exception to separate media exceptions.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaNotEjectedException(const std::string &name)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual ~MediaException()
Dtor.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaNotADirException(const Url &url_r, const Pathname &path_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaBadCAException(const Url &url_r, const std::string &msg="")
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaSystemException(const Url &url_r, const std::string &message_r)
MediaFileNotFoundException(const Url &url_r, const Pathname &filename_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaBadFilenameException(const std::string &filename_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaWriteException(const Pathname &filename_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Base class for Exception.
Definition: Exception.h:145
MediaBadUrlException(const Url &url_r, const std::string &msg_r=std::string())
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
const std::string & mountOutput() const
MediaNotOpenException(const std::string &action_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaTimeoutException(const Url &url_r, const std::string &msg="")
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaException(const std::string &msg_r)
Ctor taking message.
MediaCurlException(const Url &url_r, const std::string &err_r, const std::string &msg_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Url manipulation class.
Definition: Url.h:87
MediaUnmountException(const std::string &error_r, const std::string &path_r)
Ctor taking message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaIsSharedException(const std::string &name)
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:195