libzypp  15.28.6
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 #include "zypp/ByteCount.h"
24 
26 namespace zypp
27 {
28  namespace media {
30  //
31  // CLASS NAME : MediaException
35  class MediaException : public Exception
36  {
37  public:
41  MediaException() : Exception( "Media Exception" )
42  {}
46  MediaException( const std::string & msg_r )
47  : Exception( msg_r )
48  {}
49 
51  virtual ~MediaException() throw() {};
52  };
53 
55  {
56  public:
58  : MediaException( "Media Mount Exception" )
59  {}
60 
64  MediaMountException( const std::string & error_r,
65  const std::string & source_r,
66  const std::string & target_r,
67  const std::string & cmdout_r="")
68  : MediaException()
69  , _error(error_r)
70  , _source(source_r)
71  , _target(target_r)
72  , _cmdout(cmdout_r)
73  {}
75  virtual ~MediaMountException() throw() {};
76 
77  const std::string & mountError() const
78  { return _error; }
79  const std::string & mountSource() const
80  { return _source; }
81  const std::string & mountTarget() const
82  { return _target; }
83  const std::string & mountOutput() const
84  { return _cmdout; }
85 
86  protected:
87  virtual std::ostream & dumpOn( std::ostream & str ) const;
88  private:
89  std::string _error;
90  std::string _source;
91  std::string _target;
92  std::string _cmdout;
93  };
94 
96  {
97  public:
101  MediaUnmountException( const std::string & error_r,
102  const std::string & path_r )
103  : MediaException()
104  , _error(error_r)
105  , _path(path_r)
106  {}
108  virtual ~MediaUnmountException() throw() {};
109  protected:
110  virtual std::ostream & dumpOn( std::ostream & str ) const;
111  private:
112  std::string _error;
113  std::string _path;
114  };
115 
117  {
118  public:
119  MediaBadFilenameException(const std::string & filename_r)
120  : MediaException()
121  , _filename(filename_r)
122  {}
123  virtual ~MediaBadFilenameException() throw() {};
124  std::string filename() const { return _filename; }
125  protected:
126  virtual std::ostream & dumpOn( std::ostream & str ) const;
127  private:
128  std::string _filename;
129  };
130 
132  {
133  public:
134  MediaNotOpenException(const std::string & action_r)
135  : MediaException()
136  , _action(action_r)
137  {}
138  virtual ~MediaNotOpenException() throw() {};
139  protected:
140  virtual std::ostream & dumpOn( std::ostream & str ) const;
141  private:
142  std::string _action;
143  };
144 
146  {
147  public:
149  const Pathname & filename_r)
150  : MediaException()
151  , _url(url_r.asString())
152  , _filename(filename_r.asString())
153  {}
154  virtual ~MediaFileNotFoundException() throw() {};
155  protected:
156  virtual std::ostream & dumpOn( std::ostream & str ) const;
157  private:
158  std::string _url;
159  std::string _filename;
160  };
161 
163  {
164  public:
165  MediaWriteException(const Pathname & filename_r)
166  : MediaException()
167  , _filename(filename_r.asString())
168  {}
169  virtual ~MediaWriteException() throw() {};
170  protected:
171  virtual std::ostream & dumpOn( std::ostream & str ) const;
172  private:
173  std::string _filename;
174  };
175 
177  {
178  public:
180  : MediaException()
181  , _url(url_r.asString())
182  {}
183  virtual ~MediaNotAttachedException() throw() {};
184  protected:
185  virtual std::ostream & dumpOn( std::ostream & str ) const;
186  private:
187  std::string _url;
188  };
189 
191  {
192  public:
194  : MediaException()
195  , _url(url_r.asString())
196  {}
197  virtual ~MediaBadAttachPointException() throw() {};
198  protected:
199  virtual std::ostream & dumpOn( std::ostream & str ) const;
200  private:
201  std::string _url;
202  };
203 
205  {
206  public:
208  : MediaException()
209  , _url(url_r.asString())
210  {}
211  virtual ~MediaCurlInitException() throw() {};
212  protected:
213  virtual std::ostream & dumpOn( std::ostream & str ) const;
214  private:
215  std::string _url;
216  };
217 
219  {
220  public:
221  MediaSystemException(const Url & url_r,
222  const std::string & message_r)
223  : MediaException()
224  , _url(url_r.asString())
225  , _message(message_r)
226  {}
227  virtual ~MediaSystemException() throw() {};
228  protected:
229  virtual std::ostream & dumpOn( std::ostream & str ) const;
230  private:
231  std::string _url;
232  std::string _message;
233  };
234 
236  {
237  public:
239  const Pathname & path_r)
240  : MediaException()
241  , _url(url_r.asString())
242  , _path(path_r.asString())
243  {}
244  virtual ~MediaNotAFileException() throw() {};
245  protected:
246  virtual std::ostream & dumpOn( std::ostream & str ) const;
247  private:
248  std::string _url;
249  std::string _path;
250  };
251 
253  {
254  public:
255  MediaNotADirException(const Url & url_r,
256  const Pathname & path_r)
257  : MediaException()
258  , _url(url_r.asString())
259  , _path(path_r.asString())
260  {}
261  virtual ~MediaNotADirException() throw() {};
262  protected:
263  virtual std::ostream & dumpOn( std::ostream & str ) const;
264  private:
265  std::string _url;
266  std::string _path;
267  };
268 
270  {
271  public:
272  MediaBadUrlException(const Url & url_r,
273  const std::string &msg_r = std::string())
274  : MediaException()
275  , _url(url_r.asString())
276  , _msg(msg_r)
277  {}
278  virtual ~MediaBadUrlException() throw() {};
279  protected:
280  virtual std::ostream & dumpOn( std::ostream & str ) const;
281  std::string _url;
282  std::string _msg;
283  };
284 
286  {
287  public:
289  : MediaBadUrlException(url_r)
290  {}
291  virtual ~MediaBadUrlEmptyHostException() throw() {};
292  protected:
293  virtual std::ostream & dumpOn( std::ostream & str ) const;
294  };
295 
297  {
298  public:
300  : MediaBadUrlException(url_r)
301  {}
303  protected:
304  virtual std::ostream & dumpOn( std::ostream & str ) const;
305  };
306 
308  {
309  public:
311  : MediaBadUrlException(url_r)
312  {}
314  protected:
315  virtual std::ostream & dumpOn( std::ostream & str ) const;
316  };
317 
319  {
320  public:
322  : MediaBadUrlException(url_r)
323  {}
325  protected:
326  virtual std::ostream & dumpOn( std::ostream & str ) const;
327  };
328 
330  {
331  public:
333  : MediaException()
334  , _url(url_r.asString())
335  {}
336  virtual ~MediaNotSupportedException() throw() {};
337  protected:
338  virtual std::ostream & dumpOn( std::ostream & str ) const;
339  std::string _url;
340  };
341 
343  {
344  public:
345  MediaCurlException(const Url & url_r,
346  const std::string & err_r,
347  const std::string & msg_r)
348  : MediaException()
349  , _url(url_r.asString())
350  , _err(err_r)
351  , _msg(msg_r)
352  {}
353  virtual ~MediaCurlException() throw() {};
354  std::string errstr() const { return _err; }
355  protected:
356  virtual std::ostream & dumpOn( std::ostream & str ) const;
357  std::string _url;
358  std::string _err;
359  std::string _msg;
360  };
361 
363  {
364  public:
365  MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
366  : MediaException()
367  , _url(url_r.asString())
368  , _msg(msg_r)
369  {}
370  virtual ~MediaCurlSetOptException() throw() {};
371  protected:
372  virtual std::ostream & dumpOn( std::ostream & str ) const;
373  std::string _url;
374  std::string _msg;
375  };
376 
378  {
379  public:
381  : MediaException()
382  , _url(url_r.asString())
383  {}
384  virtual ~MediaNotDesiredException() throw() {};
385  protected:
386  virtual std::ostream & dumpOn( std::ostream & str ) const;
387  private:
388  std::string _url;
389  };
390 
392  {
393  public:
397  MediaIsSharedException(const std::string &name)
398  : MediaException()
399  , _name(name)
400  {}
401  virtual ~MediaIsSharedException() throw() {};
402  protected:
403  virtual std::ostream & dumpOn( std::ostream & str ) const;
404  private:
405  std::string _name;
406  };
407 
409  {
410  public:
412  : MediaException("Can't eject any media")
413  , _name("")
414  {}
415 
416  MediaNotEjectedException(const std::string &name)
417  : MediaException("Can't eject media")
418  , _name(name)
419  {}
420  virtual ~MediaNotEjectedException() throw() {};
421  protected:
422  virtual std::ostream & dumpOn( std::ostream & str ) const;
423  private:
424  std::string _name;
425  };
426 
428  {
429  public:
431  : MediaException("Unauthorized media access")
432  , _url("")
433  , _err("")
434  , _hint("")
435  {}
436 
438  const std::string &msg_r,
439  const std::string &err_r,
440  const std::string &hint_r)
441  : MediaException(msg_r)
442  , _url(url_r)
443  , _err(err_r)
444  , _hint(hint_r)
445  {}
446 
447  virtual ~MediaUnauthorizedException() throw() {};
448 
449  const Url & url() const { return _url; }
450  const std::string & err() const { return _err; }
452  const std::string & hint() const { return _hint; }
453 
454  protected:
455  virtual std::ostream & dumpOn( std::ostream & str ) const;
456  private:
458  std::string _err;
459  std::string _hint;
460  };
461 
463  {
464  public:
465  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
467  , _url(url_r.asString()), _msg(msg)
468  {}
469  virtual ~MediaForbiddenException() throw() {};
470  protected:
471  virtual std::ostream & dumpOn( std::ostream & str ) const;
472  std::string _url;
473  std::string _msg;
474  };
475 
477  {
478  public:
479  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
481  , _url(url_r.asString()), _msg(msg)
482  {}
483  virtual ~MediaTimeoutException() throw() {};
484  protected:
485  virtual std::ostream & dumpOn( std::ostream & str ) const;
486  std::string _url;
487  std::string _msg;
488  };
489 
491  {
492  public:
493  MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
495  , _url(url_r.asString())
496  , _msg(msg)
497  , _expectedFileSize(cnt_r)
498  {}
499  virtual ~MediaFileSizeExceededException() throw() {};
500  protected:
501  virtual std::ostream & dumpOn( std::ostream & str ) const;
502  std::string _url;
503  std::string _msg;
505  };
506 
509  {
510  public:
511  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
513  , _url(url_r.asString()), _msg(msg)
514  {}
515  virtual ~MediaTemporaryProblemException() throw() {};
516  protected:
517  virtual std::ostream & dumpOn( std::ostream & str ) const;
518  std::string _url;
519  std::string _msg;
520  };
521 
523  {
524  public:
525  MediaBadCAException(const Url & url_r, const std::string & msg = "")
527  , _url(url_r.asString()), _msg(msg)
528  {}
529  virtual ~MediaBadCAException() throw() {};
530  protected:
531  virtual std::ostream & dumpOn( std::ostream & str ) const;
532  std::string _url;
533  std::string _msg;
534  };
535 
546  {
547  public:
548  MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "")
550  , _url(url_r.asString()), _msg(msg)
551  {}
552  virtual ~MediaNoLoopDeviceException() throw() {};
553  protected:
554  virtual std::ostream & dumpOn( std::ostream & str ) const;
555  std::string _url;
556  std::string _msg;
557  };
559  } // namespace media
560 } // namespace zypp
562 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
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.
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
MediaFileSizeExceededException(const Url &url_r, const ByteCount &cnt_r, const std::string &msg="")
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:185
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)
Store and operate with byte count.
Definition: ByteCount.h:30
MediaUnauthorizedException(const Url &url_r, const std::string &msg_r, const std::string &err_r, const std::string &hint_r)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaCurlSetOptException(const Url &url_r, const std::string &msg_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.
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.
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.
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.
const std::string & mountSource() const
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.
const std::string & err() const
std::string asString() const
Error message provided by dumpOn as string.
Definition: Exception.cc:59
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.
MediaNoLoopDeviceException(const Url &url_r, const std::string &msg="")
const std::string & mountError() const
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Thrown if /sbin/losetup fails to find an unused loop device for mounting an .iso image.
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)
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:143
const std::string & hint() const
comma separated list of available authentication types
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
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaNotOpenException(const std::string &action_r)
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.
MediaException(const std::string &msg_r)
Ctor taking message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
MediaCurlException(const Url &url_r, const std::string &err_r, const std::string &msg_r)
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)