libzypp  17.37.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 <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  : MediaException()
168  , _url(url_r.asString())
169  {}
171  const Pathname & filename_r)
172  : MediaException()
173  , _url(url_r.asString())
174  , _filename(filename_r.asString())
175  {}
176  ~MediaFileNotFoundException() noexcept override {}
177  protected:
178  std::ostream & dumpOn( std::ostream & str ) const override;
179  private:
180  std::string _url;
181  std::string _filename;
182  };
183 
185  {
186  public:
187  MediaWriteException(const Pathname & filename_r)
188  : MediaException()
189  , _filename(filename_r.asString())
190  {}
191  ~MediaWriteException() noexcept override {}
192  protected:
193  std::ostream & dumpOn( std::ostream & str ) const override;
194  private:
195  std::string _filename;
196  };
197 
199  {
200  public:
202  : MediaException()
203  , _url(url_r.asString())
204  {}
205  ~MediaNotAttachedException() noexcept override {}
206  protected:
207  std::ostream & dumpOn( std::ostream & str ) const override;
208  private:
209  std::string _url;
210  };
211 
213  {
214  public:
216  : MediaException()
217  , _url(url_r.asString())
218  {}
219  ~MediaBadAttachPointException() noexcept override {}
220  protected:
221  std::ostream & dumpOn( std::ostream & str ) const override;
222  private:
223  std::string _url;
224  };
225 
227  {
228  public:
230  : MediaException()
231  , _url(url_r.asString())
232  {}
233  ~MediaCurlInitException() noexcept override {}
234  protected:
235  std::ostream & dumpOn( std::ostream & str ) const override;
236  private:
237  std::string _url;
238  };
239 
241  {
242  public:
243  MediaSystemException(const Url & url_r,
244  std::string message_r)
245  : MediaException()
246  , _url(url_r.asString())
247  , _message(std::move(message_r))
248  {}
249  ~MediaSystemException() noexcept override {}
250  protected:
251  std::ostream & dumpOn( std::ostream & str ) const override;
252  private:
253  std::string _url;
254  std::string _message;
255  };
256 
258  {
259  public:
261  const Pathname & path_r)
262  : MediaException()
263  , _url(url_r.asString())
264  , _path(path_r.asString())
265  {}
266  ~MediaNotAFileException() noexcept override {}
267  protected:
268  std::ostream & dumpOn( std::ostream & str ) const override;
269  private:
270  std::string _url;
271  std::string _path;
272  };
273 
275  {
276  public:
277  MediaNotADirException(const Url & url_r,
278  const Pathname & path_r)
279  : MediaException()
280  , _url(url_r.asString())
281  , _path(path_r.asString())
282  {}
283  ~MediaNotADirException() noexcept override {}
284  protected:
285  std::ostream & dumpOn( std::ostream & str ) const override;
286  private:
287  std::string _url;
288  std::string _path;
289  };
290 
292  {
293  public:
294  MediaBadUrlException(const Url & url_r,
295  std::string msg_r = std::string())
296  : MediaException()
297  , _url(url_r.asString())
298  , _msg(std::move(msg_r))
299  {}
300  ~MediaBadUrlException() noexcept override {}
301  protected:
302  std::ostream & dumpOn( std::ostream & str ) const override;
303  std::string _url;
304  std::string _msg;
305  };
306 
308  {
309  public:
311  : MediaBadUrlException(url_r)
312  {}
313  ~MediaBadUrlEmptyHostException() noexcept override {}
314  protected:
315  std::ostream & dumpOn( std::ostream & str ) const override;
316  };
317 
319  {
320  public:
322  : MediaBadUrlException(url_r)
323  {}
325  protected:
326  std::ostream & dumpOn( std::ostream & str ) const override;
327  };
328 
330  {
331  public:
333  : MediaBadUrlException(url_r)
334  {}
336  protected:
337  std::ostream & dumpOn( std::ostream & str ) const override;
338  };
339 
341  {
342  public:
344  : MediaBadUrlException(url_r)
345  {}
346  ~MediaUnsupportedUrlSchemeException() noexcept override {}
347  protected:
348  std::ostream & dumpOn( std::ostream & str ) const override;
349  };
350 
352  {
353  public:
355  : MediaException()
356  , _url(url_r.asString())
357  {}
358  ~MediaNotSupportedException() noexcept override {}
359  protected:
360  std::ostream & dumpOn( std::ostream & str ) const override;
361  std::string _url;
362  };
363 
365  {
366  public:
367  MediaCurlException(const Url & url_r,
368  std::string err_r,
369  std::string msg_r)
370  : MediaException()
371  , _url(url_r.asString())
372  , _err(std::move(err_r))
373  , _msg(std::move(msg_r))
374  {}
375  ~MediaCurlException() noexcept override {}
376  std::string errstr() const { return _err; }
377  protected:
378  std::ostream & dumpOn( std::ostream & str ) const override;
379  std::string _url;
380  std::string _err;
381  std::string _msg;
382  };
383 
385  {
386  public:
387  MediaCurlSetOptException(const Url & url_r, std::string msg_r)
388  : MediaException()
389  , _url(url_r.asString())
390  , _msg(std::move(msg_r))
391  {}
392  ~MediaCurlSetOptException() noexcept override {}
393  protected:
394  std::ostream & dumpOn( std::ostream & str ) const override;
395  std::string _url;
396  std::string _msg;
397  };
398 
400  {
401  public:
403  : MediaException()
404  , _url(url_r.asString())
405  {}
406  ~MediaNotDesiredException() noexcept override {}
407  protected:
408  std::ostream & dumpOn( std::ostream & str ) const override;
409  private:
410  std::string _url;
411  };
412 
414  {
415  public:
419  MediaIsSharedException(std::string name)
420  : MediaException()
421  , _name(std::move(name))
422  {}
423  ~MediaIsSharedException() noexcept override {}
424  protected:
425  std::ostream & dumpOn( std::ostream & str ) const override;
426  private:
427  std::string _name;
428  };
429 
431  {
432  public:
434  : MediaException("Can't eject any media")
435  , _name("")
436  {}
437 
438  MediaNotEjectedException(std::string name)
439  : MediaException("Can't eject media")
440  , _name(std::move(name))
441  {}
442  ~MediaNotEjectedException() noexcept override {}
443  protected:
444  std::ostream & dumpOn( std::ostream & str ) const override;
445  private:
446  std::string _name;
447  };
448 
450  {
451  public:
453  : MediaException("Unauthorized media access")
454  , _url("")
455  , _err("")
456  , _hint("")
457  {}
458 
460  const std::string &msg_r,
461  std::string err_r,
462  std::string hint_r)
463  : MediaException(msg_r)
464  , _url(std::move(url_r))
465  , _err(std::move(err_r))
466  , _hint(std::move(hint_r))
467  {}
468 
469  ~MediaUnauthorizedException() noexcept override {}
470 
471  const Url & url() const { return _url; }
472  const std::string & err() const { return _err; }
474  const std::string & hint() const { return _hint; }
475 
476  protected:
477  std::ostream & dumpOn( std::ostream & str ) const override;
478  private:
480  std::string _err;
481  std::string _hint;
482  };
483 
485  {
486  public:
487  MediaForbiddenException(const Url & url_r, const std::string & msg = "")
488  : MediaException(msg)
489  , _url(url_r.asString()), _msg(msg)
490  {}
491  ~MediaForbiddenException() noexcept override {}
492  protected:
493  std::ostream & dumpOn( std::ostream & str ) const override;
494  std::string _url;
495  std::string _msg;
496  };
497 
499  {
500  public:
501  MediaTimeoutException(const Url & url_r, const std::string & msg = "")
502  : MediaException(msg)
503  , _url(url_r.asString()), _msg(msg)
504  {}
505  ~MediaTimeoutException() noexcept override {}
506  protected:
507  std::ostream & dumpOn( std::ostream & str ) const override;
508  std::string _url;
509  std::string _msg;
510  };
511 
513  {
514  public:
515  MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
516  : MediaException(msg)
517  , _url(url_r.asString())
518  , _msg(msg)
519  , _expectedFileSize(cnt_r)
520  {}
521  ~MediaFileSizeExceededException() noexcept override {}
522  protected:
523  std::ostream & dumpOn( std::ostream & str ) const override;
524  std::string _url;
525  std::string _msg;
527  };
528 
531  {
532  public:
533  MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
534  : MediaException(msg)
535  , _url(url_r.asString()), _msg(msg)
536  {}
537  ~MediaTemporaryProblemException() noexcept override {}
538  protected:
539  std::ostream & dumpOn( std::ostream & str ) const override;
540  std::string _url;
541  std::string _msg;
542  };
543 
545  {
546  public:
547  MediaBadCAException(const Url & url_r, const std::string & msg = "")
548  : MediaException(msg)
549  , _url(url_r.asString()), _msg(msg)
550  {}
551  ~MediaBadCAException() noexcept override {}
552  protected:
553  std::ostream & dumpOn( std::ostream & str ) const override;
554  std::string _url;
555  std::string _msg;
556  };
557 
559  {
560  public:
561  MediaInvalidCredentialsException( const std::string & msg = "" )
562  : MediaException(msg)
563  {}
564  ~MediaInvalidCredentialsException() noexcept override {}
565  };
566 
568  {
569  public:
570  MediaRequestCancelledException( const std::string & msg = "" )
571  : MediaException(msg)
572  {}
573  ~MediaRequestCancelledException() noexcept override {}
574  };
575 
577  } // namespace media
578 } // namespace zypp
580 #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
~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:152
~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:92
~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