libzypp  17.31.31
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-core/base/Exception.h>
21 #include <zypp-core/Pathname.h>
22 #include <zypp-core/Url.h>
23 #include <zypp-core/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() noexcept override;
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() noexcept {}
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() noexcept {}
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:
122  MediaJammedException() : MediaException( "Media Jammed Exception" )
123  {}
124 
126  ~MediaJammedException() noexcept override {};
127  protected:
128  std::ostream & dumpOn( std::ostream & str ) const override;
129 
130  private:
131  };
132 
134  {
135  public:
136  MediaBadFilenameException(const std::string & filename_r)
137  : MediaException()
138  , _filename(filename_r)
139  {}
140  virtual ~MediaBadFilenameException() noexcept {}
141  std::string filename() const { return _filename; }
142  protected:
143  virtual std::ostream & dumpOn( std::ostream & str ) const;
144  private:
145  std::string _filename;
146  };
147 
149  {
150  public:
151  MediaNotOpenException(const std::string & action_r)
152  : MediaException()
153  , _action(action_r)
154  {}
155  virtual ~MediaNotOpenException() noexcept {}
156  protected:
157  virtual std::ostream & dumpOn( std::ostream & str ) const;
158  private:
159  std::string _action;
160  };
161 
163  {
164  public:
166  const Pathname & filename_r)
167  : MediaException()
168  , _url(url_r.asString())
169  , _filename(filename_r.asString())
170  {}
171  virtual ~MediaFileNotFoundException() noexcept {}
172  protected:
173  virtual std::ostream & dumpOn( std::ostream & str ) const;
174  private:
175  std::string _url;
176  std::string _filename;
177  };
178 
180  {
181  public:
182  MediaWriteException(const Pathname & filename_r)
183  : MediaException()
184  , _filename(filename_r.asString())
185  {}
186  virtual ~MediaWriteException() noexcept {}
187  protected:
188  virtual std::ostream & dumpOn( std::ostream & str ) const;
189  private:
190  std::string _filename;
191  };
192 
194  {
195  public:
197  : MediaException()
198  , _url(url_r.asString())
199  {}
200  virtual ~MediaNotAttachedException() noexcept {}
201  protected:
202  virtual std::ostream & dumpOn( std::ostream & str ) const;
203  private:
204  std::string _url;
205  };
206 
208  {
209  public:
211  : MediaException()
212  , _url(url_r.asString())
213  {}
214  virtual ~MediaBadAttachPointException() noexcept {}
215  protected:
216  virtual std::ostream & dumpOn( std::ostream & str ) const;
217  private:
218  std::string _url;
219  };
220 
222  {
223  public:
225  : MediaException()
226  , _url(url_r.asString())
227  {}
228  virtual ~MediaCurlInitException() noexcept {}
229  protected:
230  virtual std::ostream & dumpOn( std::ostream & str ) const;
231  private:
232  std::string _url;
233  };
234 
236  {
237  public:
238  MediaSystemException(const Url & url_r,
239  const std::string & message_r)
240  : MediaException()
241  , _url(url_r.asString())
242  , _message(message_r)
243  {}
244  virtual ~MediaSystemException() noexcept {}
245  protected:
246  virtual std::ostream & dumpOn( std::ostream & str ) const;
247  private:
248  std::string _url;
249  std::string _message;
250  };
251 
253  {
254  public:
256  const Pathname & path_r)
257  : MediaException()
258  , _url(url_r.asString())
259  , _path(path_r.asString())
260  {}
261  virtual ~MediaNotAFileException() noexcept {}
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  MediaNotADirException(const Url & url_r,
273  const Pathname & path_r)
274  : MediaException()
275  , _url(url_r.asString())
276  , _path(path_r.asString())
277  {}
278  virtual ~MediaNotADirException() noexcept {}
279  protected:
280  virtual std::ostream & dumpOn( std::ostream & str ) const;
281  private:
282  std::string _url;
283  std::string _path;
284  };
285 
287  {
288  public:
289  MediaBadUrlException(const Url & url_r,
290  const std::string &msg_r = std::string())
291  : MediaException()
292  , _url(url_r.asString())
293  , _msg(msg_r)
294  {}
295  virtual ~MediaBadUrlException() noexcept {}
296  protected:
297  virtual std::ostream & dumpOn( std::ostream & str ) const;
298  std::string _url;
299  std::string _msg;
300  };
301 
303  {
304  public:
306  : MediaBadUrlException(url_r)
307  {}
308  virtual ~MediaBadUrlEmptyHostException() noexcept {}
309  protected:
310  virtual std::ostream & dumpOn( std::ostream & str ) const;
311  };
312 
314  {
315  public:
317  : MediaBadUrlException(url_r)
318  {}
320  protected:
321  virtual std::ostream & dumpOn( std::ostream & str ) const;
322  };
323 
325  {
326  public:
328  : MediaBadUrlException(url_r)
329  {}
331  protected:
332  virtual std::ostream & dumpOn( std::ostream & str ) const;
333  };
334 
336  {
337  public:
339  : MediaBadUrlException(url_r)
340  {}
342  protected:
343  virtual std::ostream & dumpOn( std::ostream & str ) const;
344  };
345 
347  {
348  public:
350  : MediaException()
351  , _url(url_r.asString())
352  {}
353  virtual ~MediaNotSupportedException() noexcept {}
354  protected:
355  virtual std::ostream & dumpOn( std::ostream & str ) const;
356  std::string _url;
357  };
358 
360  {
361  public:
362  MediaCurlException(const Url & url_r,
363  const std::string & err_r,
364  const std::string & msg_r)
365  : MediaException()
366  , _url(url_r.asString())
367  , _err(err_r)
368  , _msg(msg_r)
369  {}
370  virtual ~MediaCurlException() noexcept {}
371  std::string errstr() const { return _err; }
372  protected:
373  virtual std::ostream & dumpOn( std::ostream & str ) const;
374  std::string _url;
375  std::string _err;
376  std::string _msg;
377  };
378 
380  {
381  public:
382  MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
383  : MediaException()
384  , _url(url_r.asString())
385  , _msg(msg_r)
386  {}
387  virtual ~MediaCurlSetOptException() noexcept {}
388  protected:
389  virtual std::ostream & dumpOn( std::ostream & str ) const;
390  std::string _url;
391  std::string _msg;
392  };
393 
395  {
396  public:
398  : MediaException()
399  , _url(url_r.asString())
400  {}
401  virtual ~MediaNotDesiredException() noexcept {}
402  protected:
403  virtual std::ostream & dumpOn( std::ostream & str ) const;
404  private:
405  std::string _url;
406  };
407 
409  {
410  public:
414  MediaIsSharedException(const std::string &name)
415  : MediaException()
416  , _name(name)
417  {}
418  virtual ~MediaIsSharedException() noexcept {}
419  protected:
420  virtual std::ostream & dumpOn( std::ostream & str ) const;
421  private:
422  std::string _name;
423  };
424 
426  {
427  public:
429  : MediaException("Can't eject any media")
430  , _name("")
431  {}
432 
433  MediaNotEjectedException(const std::string &name)
434  : MediaException("Can't eject media")
435  , _name(name)
436  {}
437  virtual ~MediaNotEjectedException() noexcept {}
438  protected:
439  virtual std::ostream & dumpOn( std::ostream & str ) const;
440  private:
441  std::string _name;
442  };
443 
445  {
446  public:
448  : MediaException("Unauthorized media access")
449  , _url("")
450  , _err("")
451  , _hint("")
452  {}
453 
455  const std::string &msg_r,
456  const std::string &err_r,
457  const std::string &hint_r)
458  : MediaException(msg_r)
459  , _url(url_r)
460  , _err(err_r)
461  , _hint(hint_r)
462  {}
463 
464  virtual ~MediaUnauthorizedException() noexcept {}
465 
466  const Url & url() const { return _url; }
467  const std::string & err() const { return _err; }
469  const std::string & hint() const { return _hint; }
470 
471  protected:
472  virtual std::ostream & dumpOn( std::ostream & str ) const;
473  private:
475  std::string _err;
476  std::string _hint;
477  };
478 
480  {
481  public:
482  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
484  , _url(url_r.asString()), _msg(msg)
485  {}
486  virtual ~MediaForbiddenException() noexcept {}
487  protected:
488  virtual std::ostream & dumpOn( std::ostream & str ) const;
489  std::string _url;
490  std::string _msg;
491  };
492 
494  {
495  public:
496  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
498  , _url(url_r.asString()), _msg(msg)
499  {}
500  virtual ~MediaTimeoutException() noexcept {}
501  protected:
502  virtual std::ostream & dumpOn( std::ostream & str ) const;
503  std::string _url;
504  std::string _msg;
505  };
506 
508  {
509  public:
510  MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
512  , _url(url_r.asString())
513  , _msg(msg)
514  , _expectedFileSize(cnt_r)
515  {}
516  virtual ~MediaFileSizeExceededException() noexcept {}
517  protected:
518  virtual std::ostream & dumpOn( std::ostream & str ) const;
519  std::string _url;
520  std::string _msg;
522  };
523 
526  {
527  public:
528  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
530  , _url(url_r.asString()), _msg(msg)
531  {}
532  virtual ~MediaTemporaryProblemException() noexcept {}
533  protected:
534  virtual std::ostream & dumpOn( std::ostream & str ) const;
535  std::string _url;
536  std::string _msg;
537  };
538 
540  {
541  public:
542  MediaBadCAException(const Url & url_r, const std::string & msg = "")
544  , _url(url_r.asString()), _msg(msg)
545  {}
546  virtual ~MediaBadCAException() noexcept {}
547  protected:
548  virtual std::ostream & dumpOn( std::ostream & str ) const;
549  std::string _url;
550  std::string _msg;
551  };
552 
554  {
555  public:
556  MediaInvalidCredentialsException( const std::string & msg = "" )
558  {}
559  virtual ~MediaInvalidCredentialsException() noexcept {}
560  };
561 
563  {
564  public:
565  MediaRequestCancelledException( const std::string & msg = "" )
567  {}
568  virtual ~MediaRequestCancelledException() noexcept {}
569  };
570 
572  } // namespace media
573 } // namespace zypp
575 #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.
const std::string & mountError() const
MediaTemporaryProblemException(const Url &url_r, const std::string &msg="")
MediaFileSizeExceededException(const Url &url_r, const ByteCount &cnt_r, const std::string &msg="")
const std::string & mountTarget() const
const std::string & mountSource() const
virtual ~MediaException() noexcept override
Dtor.
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)
gpgme_error_t _err
Definition: KeyManager.cc:64
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: Exception.cc:161
MediaCurlSetOptException(const Url &url_r, const std::string &msg_r)
String related utilities and Regular expression matching.
virtual ~MediaCurlSetOptException() noexcept
virtual ~MediaNotADirException() noexcept
virtual ~MediaNotAFileException() noexcept
const std::string & err() const
virtual ~MediaNotEjectedException() noexcept
virtual ~MediaBadCAException() noexcept
std::string _msg
Definition: Exception.h:309
MediaForbiddenException(const Url &url_r, const std::string &msg="")
~MediaJammedException() noexcept override
Dtor.
virtual ~MediaIsSharedException() noexcept
virtual ~MediaNotDesiredException() noexcept
MediaException()
Ctor taking message.
const std::string & hint() const
comma separated list of available authentication types
virtual ~MediaSystemException() noexcept
std::string asString() const
Error message provided by dumpOn as string.
Definition: Exception.cc:75
Just inherits Exception to separate media exceptions.
virtual ~MediaWriteException() noexcept
MediaNotEjectedException(const std::string &name)
virtual ~MediaForbiddenException() noexcept
MediaJammedException()
Ctor taking message.
MediaNotADirException(const Url &url_r, const Pathname &path_r)
virtual ~MediaUnmountException() noexcept
Dtor.
virtual ~MediaMountException() noexcept
Dtor.
MediaBadCAException(const Url &url_r, const std::string &msg="")
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 ~MediaCurlException() noexcept
MediaWriteException(const Pathname &filename_r)
Base class for Exception.
Definition: Exception.h:145
MediaBadUrlException(const Url &url_r, const std::string &msg_r=std::string())
const std::string & mountOutput() const
MediaNotOpenException(const std::string &action_r)
virtual ~MediaBadUrlException() noexcept
MediaInvalidCredentialsException(const std::string &msg="")
MediaTimeoutException(const Url &url_r, const std::string &msg="")
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
MediaRequestCancelledException(const std::string &msg="")
virtual ~MediaCurlInitException() noexcept
MediaException(const std::string &msg_r)
Ctor taking message.
virtual ~MediaNotOpenException() noexcept
MediaCurlException(const Url &url_r, const std::string &err_r, const std::string &msg_r)
Url manipulation class.
Definition: Url.h:91
MediaUnmountException(const std::string &error_r, const std::string &path_r)
Ctor taking message.
virtual ~MediaTimeoutException() noexcept
MediaIsSharedException(const std::string &name)
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:195