libzypp  17.35.14
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 <utility>
19 #include <vector>
20 
22 #include <zypp-core/Pathname.h>
23 #include <zypp-core/Url.h>
24 #include <zypp-core/ByteCount.h>
25 
27 namespace zypp
28 {
29  namespace media {
31  //
32  // CLASS NAME : MediaException
37  {
38  public:
42  MediaException() : Exception( "Media Exception" )
43  {}
47  MediaException( const std::string & msg_r )
48  : Exception( msg_r )
49  {}
50 
52  ~MediaException() noexcept override;
53  };
54 
56  {
57  public:
59  : MediaException( "Media Mount Exception" )
60  {}
61 
65  MediaMountException( std::string error_r,
66  std::string source_r,
67  std::string target_r,
68  std::string cmdout_r="")
69  : MediaException()
70  , _error(std::move(error_r))
71  , _source(std::move(source_r))
72  , _target(std::move(target_r))
73  , _cmdout(std::move(cmdout_r))
74  {}
76  ~MediaMountException() noexcept override {}
77 
78  const std::string & mountError() const
79  { return _error; }
80  const std::string & mountSource() const
81  { return _source; }
82  const std::string & mountTarget() const
83  { return _target; }
84  const std::string & mountOutput() const
85  { return _cmdout; }
86 
87  protected:
88  std::ostream & dumpOn( std::ostream & str ) const override;
89  private:
90  std::string _error;
91  std::string _source;
92  std::string _target;
93  std::string _cmdout;
94  };
95 
97  {
98  public:
102  MediaUnmountException( std::string error_r,
103  std::string path_r )
104  : MediaException()
105  , _error(std::move(error_r))
106  , _path(std::move(path_r))
107  {}
109  ~MediaUnmountException() noexcept override {}
110  protected:
111  std::ostream & dumpOn( std::ostream & str ) const override;
112  private:
113  std::string _error;
114  std::string _path;
115  };
116 
118  {
119  public:
123  MediaJammedException() : MediaException( "Media Jammed Exception" )
124  {}
125 
127  ~MediaJammedException() noexcept override {};
128  protected:
129  std::ostream & dumpOn( std::ostream & str ) const override;
130 
131  private:
132  };
133 
135  {
136  public:
137  MediaBadFilenameException(std::string filename_r)
138  : MediaException()
139  , _filename(std::move(filename_r))
140  {}
141  ~MediaBadFilenameException() noexcept override {}
142  std::string filename() const { return _filename; }
143  protected:
144  std::ostream & dumpOn( std::ostream & str ) const override;
145  private:
146  std::string _filename;
147  };
148 
150  {
151  public:
152  MediaNotOpenException(std::string action_r)
153  : MediaException()
154  , _action(std::move(action_r))
155  {}
156  ~MediaNotOpenException() noexcept override {}
157  protected:
158  std::ostream & dumpOn( std::ostream & str ) const override;
159  private:
160  std::string _action;
161  };
162 
164  {
165  public:
167  const Pathname & filename_r)
168  : MediaException()
169  , _url(url_r.asString())
170  , _filename(filename_r.asString())
171  {}
172  ~MediaFileNotFoundException() noexcept override {}
173  protected:
174  std::ostream & dumpOn( std::ostream & str ) const override;
175  private:
176  std::string _url;
177  std::string _filename;
178  };
179 
181  {
182  public:
183  MediaWriteException(const Pathname & filename_r)
184  : MediaException()
185  , _filename(filename_r.asString())
186  {}
187  ~MediaWriteException() noexcept override {}
188  protected:
189  std::ostream & dumpOn( std::ostream & str ) const override;
190  private:
191  std::string _filename;
192  };
193 
195  {
196  public:
198  : MediaException()
199  , _url(url_r.asString())
200  {}
201  ~MediaNotAttachedException() noexcept override {}
202  protected:
203  std::ostream & dumpOn( std::ostream & str ) const override;
204  private:
205  std::string _url;
206  };
207 
209  {
210  public:
212  : MediaException()
213  , _url(url_r.asString())
214  {}
215  ~MediaBadAttachPointException() noexcept override {}
216  protected:
217  std::ostream & dumpOn( std::ostream & str ) const override;
218  private:
219  std::string _url;
220  };
221 
223  {
224  public:
226  : MediaException()
227  , _url(url_r.asString())
228  {}
229  ~MediaCurlInitException() noexcept override {}
230  protected:
231  std::ostream & dumpOn( std::ostream & str ) const override;
232  private:
233  std::string _url;
234  };
235 
237  {
238  public:
239  MediaSystemException(const Url & url_r,
240  std::string message_r)
241  : MediaException()
242  , _url(url_r.asString())
243  , _message(std::move(message_r))
244  {}
245  ~MediaSystemException() noexcept override {}
246  protected:
247  std::ostream & dumpOn( std::ostream & str ) const override;
248  private:
249  std::string _url;
250  std::string _message;
251  };
252 
254  {
255  public:
257  const Pathname & path_r)
258  : MediaException()
259  , _url(url_r.asString())
260  , _path(path_r.asString())
261  {}
262  ~MediaNotAFileException() noexcept override {}
263  protected:
264  std::ostream & dumpOn( std::ostream & str ) const override;
265  private:
266  std::string _url;
267  std::string _path;
268  };
269 
271  {
272  public:
273  MediaNotADirException(const Url & url_r,
274  const Pathname & path_r)
275  : MediaException()
276  , _url(url_r.asString())
277  , _path(path_r.asString())
278  {}
279  ~MediaNotADirException() noexcept override {}
280  protected:
281  std::ostream & dumpOn( std::ostream & str ) const override;
282  private:
283  std::string _url;
284  std::string _path;
285  };
286 
288  {
289  public:
290  MediaBadUrlException(const Url & url_r,
291  std::string msg_r = std::string())
292  : MediaException()
293  , _url(url_r.asString())
294  , _msg(std::move(msg_r))
295  {}
296  ~MediaBadUrlException() noexcept override {}
297  protected:
298  std::ostream & dumpOn( std::ostream & str ) const override;
299  std::string _url;
300  std::string _msg;
301  };
302 
304  {
305  public:
307  : MediaBadUrlException(url_r)
308  {}
309  ~MediaBadUrlEmptyHostException() noexcept override {}
310  protected:
311  std::ostream & dumpOn( std::ostream & str ) const override;
312  };
313 
315  {
316  public:
318  : MediaBadUrlException(url_r)
319  {}
321  protected:
322  std::ostream & dumpOn( std::ostream & str ) const override;
323  };
324 
326  {
327  public:
329  : MediaBadUrlException(url_r)
330  {}
332  protected:
333  std::ostream & dumpOn( std::ostream & str ) const override;
334  };
335 
337  {
338  public:
340  : MediaBadUrlException(url_r)
341  {}
342  ~MediaUnsupportedUrlSchemeException() noexcept override {}
343  protected:
344  std::ostream & dumpOn( std::ostream & str ) const override;
345  };
346 
348  {
349  public:
351  : MediaException()
352  , _url(url_r.asString())
353  {}
354  ~MediaNotSupportedException() noexcept override {}
355  protected:
356  std::ostream & dumpOn( std::ostream & str ) const override;
357  std::string _url;
358  };
359 
361  {
362  public:
363  MediaCurlException(const Url & url_r,
364  std::string err_r,
365  std::string msg_r)
366  : MediaException()
367  , _url(url_r.asString())
368  , _err(std::move(err_r))
369  , _msg(std::move(msg_r))
370  {}
371  ~MediaCurlException() noexcept override {}
372  std::string errstr() const { return _err; }
373  protected:
374  std::ostream & dumpOn( std::ostream & str ) const override;
375  std::string _url;
376  std::string _err;
377  std::string _msg;
378  };
379 
381  {
382  public:
383  MediaCurlSetOptException(const Url & url_r, std::string msg_r)
384  : MediaException()
385  , _url(url_r.asString())
386  , _msg(std::move(msg_r))
387  {}
388  ~MediaCurlSetOptException() noexcept override {}
389  protected:
390  std::ostream & dumpOn( std::ostream & str ) const override;
391  std::string _url;
392  std::string _msg;
393  };
394 
396  {
397  public:
399  : MediaException()
400  , _url(url_r.asString())
401  {}
402  ~MediaNotDesiredException() noexcept override {}
403  protected:
404  std::ostream & dumpOn( std::ostream & str ) const override;
405  private:
406  std::string _url;
407  };
408 
410  {
411  public:
415  MediaIsSharedException(std::string name)
416  : MediaException()
417  , _name(std::move(name))
418  {}
419  ~MediaIsSharedException() noexcept override {}
420  protected:
421  std::ostream & dumpOn( std::ostream & str ) const override;
422  private:
423  std::string _name;
424  };
425 
427  {
428  public:
430  : MediaException("Can't eject any media")
431  , _name("")
432  {}
433 
434  MediaNotEjectedException(std::string name)
435  : MediaException("Can't eject media")
436  , _name(std::move(name))
437  {}
438  ~MediaNotEjectedException() noexcept override {}
439  protected:
440  std::ostream & dumpOn( std::ostream & str ) const override;
441  private:
442  std::string _name;
443  };
444 
446  {
447  public:
449  : MediaException("Unauthorized media access")
450  , _url("")
451  , _err("")
452  , _hint("")
453  {}
454 
456  const std::string &msg_r,
457  std::string err_r,
458  std::string hint_r)
459  : MediaException(msg_r)
460  , _url(std::move(url_r))
461  , _err(std::move(err_r))
462  , _hint(std::move(hint_r))
463  {}
464 
465  ~MediaUnauthorizedException() noexcept override {}
466 
467  const Url & url() const { return _url; }
468  const std::string & err() const { return _err; }
470  const std::string & hint() const { return _hint; }
471 
472  protected:
473  std::ostream & dumpOn( std::ostream & str ) const override;
474  private:
476  std::string _err;
477  std::string _hint;
478  };
479 
481  {
482  public:
483  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
484  : MediaException(msg)
485  , _url(url_r.asString()), _msg(msg)
486  {}
487  ~MediaForbiddenException() noexcept override {}
488  protected:
489  std::ostream & dumpOn( std::ostream & str ) const override;
490  std::string _url;
491  std::string _msg;
492  };
493 
495  {
496  public:
497  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
498  : MediaException(msg)
499  , _url(url_r.asString()), _msg(msg)
500  {}
501  ~MediaTimeoutException() noexcept override {}
502  protected:
503  std::ostream & dumpOn( std::ostream & str ) const override;
504  std::string _url;
505  std::string _msg;
506  };
507 
509  {
510  public:
511  MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
512  : MediaException(msg)
513  , _url(url_r.asString())
514  , _msg(msg)
515  , _expectedFileSize(cnt_r)
516  {}
517  ~MediaFileSizeExceededException() noexcept override {}
518  protected:
519  std::ostream & dumpOn( std::ostream & str ) const override;
520  std::string _url;
521  std::string _msg;
523  };
524 
527  {
528  public:
529  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
530  : MediaException(msg)
531  , _url(url_r.asString()), _msg(msg)
532  {}
533  ~MediaTemporaryProblemException() noexcept override {}
534  protected:
535  std::ostream & dumpOn( std::ostream & str ) const override;
536  std::string _url;
537  std::string _msg;
538  };
539 
541  {
542  public:
543  MediaBadCAException(const Url & url_r, const std::string & msg = "")
544  : MediaException(msg)
545  , _url(url_r.asString()), _msg(msg)
546  {}
547  ~MediaBadCAException() noexcept override {}
548  protected:
549  std::ostream & dumpOn( std::ostream & str ) const override;
550  std::string _url;
551  std::string _msg;
552  };
553 
555  {
556  public:
557  MediaInvalidCredentialsException( const std::string & msg = "" )
558  : MediaException(msg)
559  {}
560  ~MediaInvalidCredentialsException() noexcept override {}
561  };
562 
564  {
565  public:
566  MediaRequestCancelledException( const std::string & msg = "" )
567  : MediaException(msg)
568  {}
569  ~MediaRequestCancelledException() noexcept override {}
570  };
571 
573  } // namespace media
574 } // namespace zypp
576 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:122
~MediaWriteException() noexcept override
const std::string & mountError() const
MediaUnmountException(std::string error_r, std::string path_r)
Ctor taking message.
MediaBadFilenameException(std::string filename_r)
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
~MediaBadFilenameException() noexcept override
const std::string & mountSource() const
MediaCurlSetOptException(const Url &url_r, std::string msg_r)
~MediaNotAttachedException() noexcept override
MediaNotAFileException(const Url &url_r, const Pathname &path_r)
Store and operate with byte count.
Definition: ByteCount.h:31
~MediaBadUrlException() noexcept override
gpgme_error_t _err
Definition: KeyManager.cc:64
~MediaNotOpenException() noexcept override
String related utilities and Regular expression matching.
MediaCurlException(const Url &url_r, std::string err_r, std::string msg_r)
Definition: Arch.h:363
const std::string & err() const
MediaMountException(std::string error_r, std::string source_r, std::string target_r, std::string cmdout_r="")
Ctor taking message.
~MediaUnauthorizedException() noexcept override
zypp::Pathname _path
~MediaTimeoutException() noexcept override
MediaForbiddenException(const Url &url_r, const std::string &msg="")
zypp::Url _url
~MediaJammedException() noexcept override
Dtor.
~MediaCurlException() noexcept override
MediaException()
Ctor taking message.
~MediaMountException() noexcept override
Dtor.
const std::string & hint() const
comma separated list of available authentication types
~MediaCurlInitException() noexcept override
zypp::repo::RepoException _error
Just inherits Exception to separate media exceptions.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
~MediaBadCAException() noexcept override
MediaSystemException(const Url &url_r, std::string message_r)
~MediaNotDesiredException() noexcept override
MediaJammedException()
Ctor taking message.
~MediaNotSupportedException() noexcept override
MediaNotADirException(const Url &url_r, const Pathname &path_r)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
~MediaUnmountException() noexcept override
Dtor.
~MediaNotADirException() noexcept override
MediaBadCAException(const Url &url_r, const std::string &msg="")
MediaFileNotFoundException(const Url &url_r, const Pathname &filename_r)
MediaNotOpenException(std::string action_r)
MediaWriteException(const Pathname &filename_r)
~MediaNotAFileException() noexcept override
Base class for Exception.
Definition: Exception.h:146
~MediaSystemException() noexcept override
~MediaCurlSetOptException() noexcept override
MediaBadUrlException(const Url &url_r, std::string msg_r=std::string())
const std::string & mountOutput() const
~MediaNotEjectedException() noexcept override
MediaInvalidCredentialsException(const std::string &msg="")
MediaTimeoutException(const Url &url_r, const std::string &msg="")
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
MediaRequestCancelledException(const std::string &msg="")
MediaException(const std::string &msg_r)
Ctor taking message.
Url manipulation class.
Definition: Url.h:91
~MediaFileNotFoundException() noexcept override
MediaUnauthorizedException(Url url_r, const std::string &msg_r, std::string err_r, std::string hint_r)
~MediaForbiddenException() noexcept override
~MediaIsSharedException() noexcept override