libzypp  11.13.5
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:
221  : MediaException()
222  , _url(url_r.asString())
223  {}
224  virtual ~MediaMetalinkInitException() throw() {};
225  protected:
226  virtual std::ostream & dumpOn( std::ostream & str ) const;
227  private:
228  std::string _url;
229  };
230 
232  {
233  public:
235  : MediaException()
236  , _url(url_r.asString())
237  {}
238  virtual ~MediaAria2cInitException() throw() {};
239  protected:
240  virtual std::ostream & dumpOn( std::ostream & str ) const;
241  private:
242  std::string _url;
243  };
244 
246  {
247  public:
248  MediaSystemException(const Url & url_r,
249  const std::string & message_r)
250  : MediaException()
251  , _url(url_r.asString())
252  , _message(message_r)
253  {}
254  virtual ~MediaSystemException() throw() {};
255  protected:
256  virtual std::ostream & dumpOn( std::ostream & str ) const;
257  private:
258  std::string _url;
259  std::string _message;
260  };
261 
263  {
264  public:
266  const Pathname & path_r)
267  : MediaException()
268  , _url(url_r.asString())
269  , _path(path_r.asString())
270  {}
271  virtual ~MediaNotAFileException() throw() {};
272  protected:
273  virtual std::ostream & dumpOn( std::ostream & str ) const;
274  private:
275  std::string _url;
276  std::string _path;
277  };
278 
280  {
281  public:
282  MediaNotADirException(const Url & url_r,
283  const Pathname & path_r)
284  : MediaException()
285  , _url(url_r.asString())
286  , _path(path_r.asString())
287  {}
288  virtual ~MediaNotADirException() throw() {};
289  protected:
290  virtual std::ostream & dumpOn( std::ostream & str ) const;
291  private:
292  std::string _url;
293  std::string _path;
294  };
295 
297  {
298  public:
299  MediaBadUrlException(const Url & url_r,
300  const std::string &msg_r = std::string())
301  : MediaException()
302  , _url(url_r.asString())
303  , _msg(msg_r)
304  {}
305  virtual ~MediaBadUrlException() throw() {};
306  protected:
307  virtual std::ostream & dumpOn( std::ostream & str ) const;
308  std::string _url;
309  std::string _msg;
310  };
311 
313  {
314  public:
316  : MediaBadUrlException(url_r)
317  {}
318  virtual ~MediaBadUrlEmptyHostException() throw() {};
319  protected:
320  virtual std::ostream & dumpOn( std::ostream & str ) const;
321  };
322 
324  {
325  public:
327  : MediaBadUrlException(url_r)
328  {}
330  protected:
331  virtual std::ostream & dumpOn( std::ostream & str ) const;
332  };
333 
335  {
336  public:
338  : MediaBadUrlException(url_r)
339  {}
341  protected:
342  virtual std::ostream & dumpOn( std::ostream & str ) const;
343  };
344 
346  {
347  public:
349  : MediaBadUrlException(url_r)
350  {}
352  protected:
353  virtual std::ostream & dumpOn( std::ostream & str ) const;
354  };
355 
357  {
358  public:
360  : MediaException()
361  , _url(url_r.asString())
362  {}
363  virtual ~MediaNotSupportedException() throw() {};
364  protected:
365  virtual std::ostream & dumpOn( std::ostream & str ) const;
366  std::string _url;
367  };
368 
370  {
371  public:
372  MediaCurlException(const Url & url_r,
373  const std::string & err_r,
374  const std::string & msg_r)
375  : MediaException()
376  , _url(url_r.asString())
377  , _err(err_r)
378  , _msg(msg_r)
379  {}
380  virtual ~MediaCurlException() throw() {};
381  std::string errstr() const { return _err; }
382  protected:
383  virtual std::ostream & dumpOn( std::ostream & str ) const;
384  std::string _url;
385  std::string _err;
386  std::string _msg;
387  };
388 
390  {
391  public:
392  MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
393  : MediaException()
394  , _url(url_r.asString())
395  , _msg(msg_r)
396  {}
397  virtual ~MediaCurlSetOptException() throw() {};
398  protected:
399  virtual std::ostream & dumpOn( std::ostream & str ) const;
400  std::string _url;
401  std::string _msg;
402  };
403 
405  {
406  public:
408  const std::string & err_r,
409  const std::string & msg_r)
410  : MediaException()
411  , _url(url_r.asString())
412  , _err(err_r)
413  , _msg(msg_r)
414  {}
415  virtual ~MediaMetalinkException() throw() {};
416  protected:
417  virtual std::ostream & dumpOn( std::ostream & str ) const;
418  std::string _url;
419  std::string _err;
420  std::string _msg;
421  };
422 
424  {
425  public:
426  MediaMetalinkSetOptException(const Url & url_r, const std::string & msg_r)
427  : MediaException()
428  , _url(url_r.asString())
429  , _msg(msg_r)
430  {}
431  virtual ~MediaMetalinkSetOptException() throw() {};
432  protected:
433  virtual std::ostream & dumpOn( std::ostream & str ) const;
434  std::string _url;
435  std::string _msg;
436  };
437 
439  {
440  public:
441  MediaAria2cException(const Url & url_r,
442  const std::string & err_r,
443  const std::string & msg_r)
444  : MediaException()
445  , _url(url_r.asString())
446  , _err(err_r)
447  , _msg(msg_r)
448  {}
449  virtual ~MediaAria2cException() throw() {};
450  protected:
451  virtual std::ostream & dumpOn( std::ostream & str ) const;
452  std::string _url;
453  std::string _err;
454  std::string _msg;
455  };
456 
458  {
459  public:
460  MediaAria2cSetOptException(const Url & url_r, const std::string & msg_r)
461  : MediaException()
462  , _url(url_r.asString())
463  , _msg(msg_r)
464  {}
465  virtual ~MediaAria2cSetOptException() throw() {};
466  protected:
467  virtual std::ostream & dumpOn( std::ostream & str ) const;
468  std::string _url;
469  std::string _msg;
470  };
471 
473  {
474  public:
476  : MediaException()
477  , _url(url_r.asString())
478  {}
479  virtual ~MediaNotDesiredException() throw() {};
480  protected:
481  virtual std::ostream & dumpOn( std::ostream & str ) const;
482  private:
483  std::string _url;
484  };
485 
487  {
488  public:
492  MediaIsSharedException(const std::string &name)
493  : MediaException()
494  , _name(name)
495  {}
496  virtual ~MediaIsSharedException() throw() {};
497  protected:
498  virtual std::ostream & dumpOn( std::ostream & str ) const;
499  private:
500  std::string _name;
501  };
502 
504  {
505  public:
507  : MediaException("Can't eject any media")
508  , _name("")
509  {}
510 
511  MediaNotEjectedException(const std::string &name)
512  : MediaException("Can't eject media")
513  , _name(name)
514  {}
515  virtual ~MediaNotEjectedException() throw() {};
516  protected:
517  virtual std::ostream & dumpOn( std::ostream & str ) const;
518  private:
519  std::string _name;
520  };
521 
523  {
524  public:
526  : MediaException("Unauthorized media access")
527  , _url("")
528  , _err("")
529  , _hint("")
530  {}
531 
533  const std::string &msg_r,
534  const std::string &err_r,
535  const std::string &hint_r)
536  : MediaException(msg_r)
537  , _url(url_r)
538  , _err(err_r)
539  , _hint(hint_r)
540  {}
541 
542  virtual ~MediaUnauthorizedException() throw() {};
543 
544  const Url & url() const { return _url; }
545  const std::string & err() const { return _err; }
547  const std::string & hint() const { return _hint; }
548 
549  protected:
550  virtual std::ostream & dumpOn( std::ostream & str ) const;
551  private:
553  std::string _err;
554  std::string _hint;
555  };
556 
558  {
559  public:
560  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
562  , _url(url_r.asString()), _msg(msg)
563  {}
564  virtual ~MediaForbiddenException() throw() {};
565  protected:
566  virtual std::ostream & dumpOn( std::ostream & str ) const;
567  std::string _url;
568  std::string _msg;
569  };
570 
572  {
573  public:
574  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
576  , _url(url_r.asString()), _msg(msg)
577  {}
578  virtual ~MediaTimeoutException() throw() {};
579  protected:
580  virtual std::ostream & dumpOn( std::ostream & str ) const;
581  std::string _url;
582  std::string _msg;
583  };
584 
587  {
588  public:
589  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
591  , _url(url_r.asString()), _msg(msg)
592  {}
593  virtual ~MediaTemporaryProblemException() throw() {};
594  protected:
595  virtual std::ostream & dumpOn( std::ostream & str ) const;
596  std::string _url;
597  std::string _msg;
598  };
599 
601  {
602  public:
603  MediaBadCAException(const Url & url_r, const std::string & msg = "")
605  , _url(url_r.asString()), _msg(msg)
606  {}
607  virtual ~MediaBadCAException() throw() {};
608  protected:
609  virtual std::ostream & dumpOn( std::ostream & str ) const;
610  std::string _url;
611  std::string _msg;
612  };
613 
624  {
625  public:
626  MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "")
628  , _url(url_r.asString()), _msg(msg)
629  {}
630  virtual ~MediaNoLoopDeviceException() throw() {};
631  protected:
632  virtual std::ostream & dumpOn( std::ostream & str ) const;
633  std::string _url;
634  std::string _msg;
635  };
637  } // namespace media
638 } // namespace zypp
640 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H