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 MediaSystemException : public MediaException
220 MediaSystemException(const Url & url_r,
221 const std::string & message_r)
223 , _url(url_r.asString())
224 , _message(message_r)
226 virtual ~MediaSystemException() throw() {};
228 virtual std::ostream & dumpOn( std::ostream & str ) const;
231 std::string _message;
234 class MediaNotAFileException : public MediaException
237 MediaNotAFileException(const Url & url_r,
238 const Pathname & path_r)
240 , _url(url_r.asString())
241 , _path(path_r.asString())
243 virtual ~MediaNotAFileException() throw() {};
245 virtual std::ostream & dumpOn( std::ostream & str ) const;
251 class MediaNotADirException : public MediaException
254 MediaNotADirException(const Url & url_r,
255 const Pathname & path_r)
257 , _url(url_r.asString())
258 , _path(path_r.asString())
260 virtual ~MediaNotADirException() throw() {};
262 virtual std::ostream & dumpOn( std::ostream & str ) const;
268 class MediaBadUrlException : public MediaException
271 MediaBadUrlException(const Url & url_r,
272 const std::string &msg_r = std::string())
274 , _url(url_r.asString())
277 virtual ~MediaBadUrlException() throw() {};
279 virtual std::ostream & dumpOn( std::ostream & str ) const;
284 class MediaBadUrlEmptyHostException : public MediaBadUrlException
287 MediaBadUrlEmptyHostException(const Url & url_r)
288 : MediaBadUrlException(url_r)
290 virtual ~MediaBadUrlEmptyHostException() throw() {};
292 virtual std::ostream & dumpOn( std::ostream & str ) const;
295 class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
298 MediaBadUrlEmptyFilesystemException(const Url & url_r)
299 : MediaBadUrlException(url_r)
301 virtual ~MediaBadUrlEmptyFilesystemException() throw() {};
303 virtual std::ostream & dumpOn( std::ostream & str ) const;
306 class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
309 MediaBadUrlEmptyDestinationException(const Url & url_r)
310 : MediaBadUrlException(url_r)
312 virtual ~MediaBadUrlEmptyDestinationException() throw() {};
314 virtual std::ostream & dumpOn( std::ostream & str ) const;
317 class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
320 MediaUnsupportedUrlSchemeException(const Url & url_r)
321 : MediaBadUrlException(url_r)
323 virtual ~MediaUnsupportedUrlSchemeException() throw() {};
325 virtual std::ostream & dumpOn( std::ostream & str ) const;
328 class MediaNotSupportedException : public MediaException
331 MediaNotSupportedException(const Url & url_r)
333 , _url(url_r.asString())
335 virtual ~MediaNotSupportedException() throw() {};
337 virtual std::ostream & dumpOn( std::ostream & str ) const;
341 class MediaCurlException : public MediaException
344 MediaCurlException(const Url & url_r,
345 const std::string & err_r,
346 const std::string & msg_r)
348 , _url(url_r.asString())
352 virtual ~MediaCurlException() throw() {};
353 std::string errstr() const { return _err; }
355 virtual std::ostream & dumpOn( std::ostream & str ) const;
361 class MediaCurlSetOptException : public MediaException
364 MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
366 , _url(url_r.asString())
369 virtual ~MediaCurlSetOptException() throw() {};
371 virtual std::ostream & dumpOn( std::ostream & str ) const;
376 class MediaNotDesiredException : public MediaException
379 MediaNotDesiredException(const Url & url_r)
381 , _url(url_r.asString())
383 virtual ~MediaNotDesiredException() throw() {};
385 virtual std::ostream & dumpOn( std::ostream & str ) const;
390 class MediaIsSharedException : public MediaException
394 * \param name A media source as string (see MediaSource class).
396 MediaIsSharedException(const std::string &name)
400 virtual ~MediaIsSharedException() throw() {};
402 virtual std::ostream & dumpOn( std::ostream & str ) const;
407 class MediaNotEjectedException: public MediaException
410 MediaNotEjectedException()
411 : MediaException("Can't eject any media")
415 MediaNotEjectedException(const std::string &name)
416 : MediaException("Can't eject media")
419 virtual ~MediaNotEjectedException() throw() {};
421 virtual std::ostream & dumpOn( std::ostream & str ) const;
426 class MediaUnauthorizedException: public MediaException
429 MediaUnauthorizedException()
430 : MediaException("Unauthorized media access")
436 MediaUnauthorizedException(const Url &url_r,
437 const std::string &msg_r,
438 const std::string &err_r,
439 const std::string &hint_r)
440 : MediaException(msg_r)
446 virtual ~MediaUnauthorizedException() throw() {};
448 const Url & url() const { return _url; }
449 const std::string & err() const { return _err; }
450 /** comma separated list of available authentication types */
451 const std::string & hint() const { return _hint; }
454 virtual std::ostream & dumpOn( std::ostream & str ) const;
461 class MediaForbiddenException : public MediaException
464 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
465 : MediaException(msg)
466 , _url(url_r.asString()), _msg(msg)
468 virtual ~MediaForbiddenException() throw() {};
470 virtual std::ostream & dumpOn( std::ostream & str ) const;
475 class MediaTimeoutException : public MediaException
478 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
479 : MediaException(msg)
480 , _url(url_r.asString()), _msg(msg)
482 virtual ~MediaTimeoutException() throw() {};
484 virtual std::ostream & dumpOn( std::ostream & str ) const;
489 /** For HTTP 503 and similar. */
490 class MediaTemporaryProblemException : public MediaException
493 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
494 : MediaException(msg)
495 , _url(url_r.asString()), _msg(msg)
497 virtual ~MediaTemporaryProblemException() throw() {};
499 virtual std::ostream & dumpOn( std::ostream & str ) const;
504 class MediaBadCAException : public MediaException
507 MediaBadCAException(const Url & url_r, const std::string & msg = "")
508 : MediaException(msg)
509 , _url(url_r.asString()), _msg(msg)
511 virtual ~MediaBadCAException() throw() {};
513 virtual std::ostream & dumpOn( std::ostream & str ) const;
519 * Thrown if /sbin/losetup fails to find an unused loop device for mounting
522 * UI hint: tell user to check permissions to read /dev/loop# or enablement
523 * of support for loop devices.
527 class MediaNoLoopDeviceException : public MediaException
530 MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "")
531 : MediaException(msg)
532 , _url(url_r.asString()), _msg(msg)
534 virtual ~MediaNoLoopDeviceException() throw() {};
536 virtual std::ostream & dumpOn( std::ostream & str ) const;
540 /////////////////////////////////////////////////////////////////
543 ///////////////////////////////////////////////////////////////////
544 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H