1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaException.h
12 #ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
13 #define ZYPP_MEDIA_MEDIAEXCEPTION_H
20 #include "zypp/base/Exception.h"
21 #include "zypp/Pathname.h"
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////
30 // CLASS NAME : MediaException
31 /** Just inherits Exception to separate media exceptions
34 class MediaException : public Exception
37 /** Ctor taking message.
38 * Use \ref ZYPP_THROW to throw exceptions.
40 MediaException() : Exception( "Media Exception" )
42 /** Ctor taking message.
43 * Use \ref ZYPP_THROW to throw exceptions.
45 MediaException( const std::string & msg_r )
50 virtual ~MediaException() throw() {};
53 class MediaMountException : public MediaException
57 : MediaException( "Media Mount Exception" )
60 /** Ctor taking message.
61 * Use \ref ZYPP_THROW to throw exceptions.
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="")
74 virtual ~MediaMountException() throw() {};
76 const std::string & mountError() const
78 const std::string & mountSource() const
80 const std::string & mountTarget() const
82 const std::string & mountOutput() const
86 virtual std::ostream & dumpOn( std::ostream & str ) const;
94 class MediaUnmountException : public MediaException
97 /** Ctor taking message.
98 * Use \ref ZYPP_THROW to throw exceptions.
100 MediaUnmountException( const std::string & error_r,
101 const std::string & path_r )
107 virtual ~MediaUnmountException() throw() {};
109 virtual std::ostream & dumpOn( std::ostream & str ) const;
115 class MediaBadFilenameException : public MediaException
118 MediaBadFilenameException(const std::string & filename_r)
120 , _filename(filename_r)
122 virtual ~MediaBadFilenameException() throw() {};
123 std::string filename() const { return _filename; }
125 virtual std::ostream & dumpOn( std::ostream & str ) const;
127 std::string _filename;
130 class MediaNotOpenException : public MediaException
133 MediaNotOpenException(const std::string & action_r)
137 virtual ~MediaNotOpenException() throw() {};
139 virtual std::ostream & dumpOn( std::ostream & str ) const;
144 class MediaFileNotFoundException : public MediaException
147 MediaFileNotFoundException(const Url & url_r,
148 const Pathname & filename_r)
150 , _url(url_r.asString())
151 , _filename(filename_r.asString())
153 virtual ~MediaFileNotFoundException() throw() {};
155 virtual std::ostream & dumpOn( std::ostream & str ) const;
158 std::string _filename;
161 class MediaWriteException : public MediaException
164 MediaWriteException(const Pathname & filename_r)
166 , _filename(filename_r.asString())
168 virtual ~MediaWriteException() throw() {};
170 virtual std::ostream & dumpOn( std::ostream & str ) const;
172 std::string _filename;
175 class MediaNotAttachedException : public MediaException
178 MediaNotAttachedException(const Url & url_r)
180 , _url(url_r.asString())
182 virtual ~MediaNotAttachedException() throw() {};
184 virtual std::ostream & dumpOn( std::ostream & str ) const;
189 class MediaBadAttachPointException : public MediaException
192 MediaBadAttachPointException(const Url & url_r)
194 , _url(url_r.asString())
196 virtual ~MediaBadAttachPointException() throw() {};
198 virtual std::ostream & dumpOn( std::ostream & str ) const;
203 class MediaCurlInitException : public MediaException
206 MediaCurlInitException(const Url & url_r)
208 , _url(url_r.asString())
210 virtual ~MediaCurlInitException() throw() {};
212 virtual std::ostream & dumpOn( std::ostream & str ) const;
217 class MediaMetalinkInitException : public MediaException
220 MediaMetalinkInitException(const Url & url_r)
222 , _url(url_r.asString())
224 virtual ~MediaMetalinkInitException() throw() {};
226 virtual std::ostream & dumpOn( std::ostream & str ) const;
231 class MediaAria2cInitException : public MediaException
234 MediaAria2cInitException(const Url & url_r)
236 , _url(url_r.asString())
238 virtual ~MediaAria2cInitException() throw() {};
240 virtual std::ostream & dumpOn( std::ostream & str ) const;
245 class MediaSystemException : public MediaException
248 MediaSystemException(const Url & url_r,
249 const std::string & message_r)
251 , _url(url_r.asString())
252 , _message(message_r)
254 virtual ~MediaSystemException() throw() {};
256 virtual std::ostream & dumpOn( std::ostream & str ) const;
259 std::string _message;
262 class MediaNotAFileException : public MediaException
265 MediaNotAFileException(const Url & url_r,
266 const Pathname & path_r)
268 , _url(url_r.asString())
269 , _path(path_r.asString())
271 virtual ~MediaNotAFileException() throw() {};
273 virtual std::ostream & dumpOn( std::ostream & str ) const;
279 class MediaNotADirException : public MediaException
282 MediaNotADirException(const Url & url_r,
283 const Pathname & path_r)
285 , _url(url_r.asString())
286 , _path(path_r.asString())
288 virtual ~MediaNotADirException() throw() {};
290 virtual std::ostream & dumpOn( std::ostream & str ) const;
296 class MediaBadUrlException : public MediaException
299 MediaBadUrlException(const Url & url_r,
300 const std::string &msg_r = std::string())
302 , _url(url_r.asString())
305 virtual ~MediaBadUrlException() throw() {};
307 virtual std::ostream & dumpOn( std::ostream & str ) const;
312 class MediaBadUrlEmptyHostException : public MediaBadUrlException
315 MediaBadUrlEmptyHostException(const Url & url_r)
316 : MediaBadUrlException(url_r)
318 virtual ~MediaBadUrlEmptyHostException() throw() {};
320 virtual std::ostream & dumpOn( std::ostream & str ) const;
323 class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
326 MediaBadUrlEmptyFilesystemException(const Url & url_r)
327 : MediaBadUrlException(url_r)
329 virtual ~MediaBadUrlEmptyFilesystemException() throw() {};
331 virtual std::ostream & dumpOn( std::ostream & str ) const;
334 class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
337 MediaBadUrlEmptyDestinationException(const Url & url_r)
338 : MediaBadUrlException(url_r)
340 virtual ~MediaBadUrlEmptyDestinationException() throw() {};
342 virtual std::ostream & dumpOn( std::ostream & str ) const;
345 class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
348 MediaUnsupportedUrlSchemeException(const Url & url_r)
349 : MediaBadUrlException(url_r)
351 virtual ~MediaUnsupportedUrlSchemeException() throw() {};
353 virtual std::ostream & dumpOn( std::ostream & str ) const;
356 class MediaNotSupportedException : public MediaException
359 MediaNotSupportedException(const Url & url_r)
361 , _url(url_r.asString())
363 virtual ~MediaNotSupportedException() throw() {};
365 virtual std::ostream & dumpOn( std::ostream & str ) const;
369 class MediaCurlException : public MediaException
372 MediaCurlException(const Url & url_r,
373 const std::string & err_r,
374 const std::string & msg_r)
376 , _url(url_r.asString())
380 virtual ~MediaCurlException() throw() {};
382 virtual std::ostream & dumpOn( std::ostream & str ) const;
388 class MediaCurlSetOptException : public MediaException
391 MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
393 , _url(url_r.asString())
396 virtual ~MediaCurlSetOptException() throw() {};
398 virtual std::ostream & dumpOn( std::ostream & str ) const;
403 class MediaMetalinkException : public MediaException
406 MediaMetalinkException(const Url & url_r,
407 const std::string & err_r,
408 const std::string & msg_r)
410 , _url(url_r.asString())
414 virtual ~MediaMetalinkException() throw() {};
416 virtual std::ostream & dumpOn( std::ostream & str ) const;
422 class MediaMetalinkSetOptException : public MediaException
425 MediaMetalinkSetOptException(const Url & url_r, const std::string & msg_r)
427 , _url(url_r.asString())
430 virtual ~MediaMetalinkSetOptException() throw() {};
432 virtual std::ostream & dumpOn( std::ostream & str ) const;
437 class MediaAria2cException : public MediaException
440 MediaAria2cException(const Url & url_r,
441 const std::string & err_r,
442 const std::string & msg_r)
444 , _url(url_r.asString())
448 virtual ~MediaAria2cException() throw() {};
450 virtual std::ostream & dumpOn( std::ostream & str ) const;
456 class MediaAria2cSetOptException : public MediaException
459 MediaAria2cSetOptException(const Url & url_r, const std::string & msg_r)
461 , _url(url_r.asString())
464 virtual ~MediaAria2cSetOptException() throw() {};
466 virtual std::ostream & dumpOn( std::ostream & str ) const;
471 class MediaNotDesiredException : public MediaException
474 MediaNotDesiredException(const Url & url_r)
476 , _url(url_r.asString())
478 virtual ~MediaNotDesiredException() throw() {};
480 virtual std::ostream & dumpOn( std::ostream & str ) const;
485 class MediaIsSharedException : public MediaException
489 * \param name A media source as string (see MediaSource class).
491 MediaIsSharedException(const std::string &name)
495 virtual ~MediaIsSharedException() throw() {};
497 virtual std::ostream & dumpOn( std::ostream & str ) const;
502 class MediaNotEjectedException: public MediaException
505 MediaNotEjectedException()
506 : MediaException("Can't eject any media")
510 MediaNotEjectedException(const std::string &name)
511 : MediaException("Can't eject media")
514 virtual ~MediaNotEjectedException() throw() {};
516 virtual std::ostream & dumpOn( std::ostream & str ) const;
521 class MediaUnauthorizedException: public MediaException
524 MediaUnauthorizedException()
525 : MediaException("Unauthorized media access")
531 MediaUnauthorizedException(const Url &url_r,
532 const std::string &msg_r,
533 const std::string &err_r,
534 const std::string &hint_r)
535 : MediaException(msg_r)
541 virtual ~MediaUnauthorizedException() throw() {};
543 const Url & url() const { return _url; }
544 const std::string & err() const { return _err; }
545 /** comma separated list of available authentication types */
546 const std::string & hint() const { return _hint; }
549 virtual std::ostream & dumpOn( std::ostream & str ) const;
556 class MediaForbiddenException : public MediaException
559 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
560 : MediaException(msg)
561 , _url(url_r.asString()), _msg(msg)
563 virtual ~MediaForbiddenException() throw() {};
565 virtual std::ostream & dumpOn( std::ostream & str ) const;
570 class MediaTimeoutException : public MediaException
573 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
574 : MediaException(msg)
575 , _url(url_r.asString()), _msg(msg)
577 virtual ~MediaTimeoutException() throw() {};
579 virtual std::ostream & dumpOn( std::ostream & str ) const;
584 /** For HTTP 503 and similar. */
585 class MediaTemporaryProblemException : public MediaException
588 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
589 : MediaException(msg)
590 , _url(url_r.asString()), _msg(msg)
592 virtual ~MediaTemporaryProblemException() throw() {};
594 virtual std::ostream & dumpOn( std::ostream & str ) const;
599 class MediaBadCAException : public MediaException
602 MediaBadCAException(const Url & url_r, const std::string & msg = "")
603 : MediaException(msg)
604 , _url(url_r.asString()), _msg(msg)
606 virtual ~MediaBadCAException() throw() {};
608 virtual std::ostream & dumpOn( std::ostream & str ) const;
614 * Thrown if /sbin/losetup fails to find an unused loop device for mounting
617 * UI hint: tell user to check permissions to read /dev/loop# or enablement
618 * of support for loop devices.
622 class MediaNoLoopDeviceException : public MediaException
625 MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "")
626 : MediaException(msg)
627 , _url(url_r.asString())
629 virtual ~MediaNoLoopDeviceException() throw() {};
631 virtual std::ostream & dumpOn( std::ostream & str ) const;
634 /////////////////////////////////////////////////////////////////
637 ///////////////////////////////////////////////////////////////////
638 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H