#include "zypp/base/Exception.h"
#include "zypp/Pathname.h"
#include "zypp/Url.h"
+#include "zypp/ByteCount.h"
///////////////////////////////////////////////////////////////////
namespace zypp
/** Ctor taking message.
* Use \ref ZYPP_THROW to throw exceptions.
*/
- MediaException() : Exception( "Media Exception" ), _dev_current(0)
+ MediaException() : Exception( "Media Exception" )
{}
/** Ctor taking message.
* Use \ref ZYPP_THROW to throw exceptions.
*/
MediaException( const std::string & msg_r )
- : Exception( msg_r ), _dev_current(0)
+ : Exception( msg_r )
{}
- /**
- * Ctor taking the message and detected device list (e.g. for ejecting).
- * \param msg_r
- * \param devices list of available devices as vector
- * \param devCurrent index of the currently used device in the \a devices vector
- */
- MediaException( const std::string & msg_r,
- const std::vector<std::string> & devices,
- unsigned int devCurrent)
- : Exception( msg_r ), _devices(devices), _dev_current(devCurrent)
- {}
-
- const std::vector<std::string> & devices() const { return _devices; }
- unsigned int deviceCurrent() const { return _dev_current; }
-
/** Dtor. */
- virtual ~MediaException() throw() {};
-
-// private:
-// void operator = (const MediaException & ex) {}
- private:
- std::vector<std::string> _devices;
- unsigned int _dev_current;
+ virtual ~MediaException() noexcept override;
};
class MediaMountException : public MediaException
, _cmdout(cmdout_r)
{}
/** Dtor. */
- virtual ~MediaMountException() throw() {};
+ virtual ~MediaMountException() noexcept {}
const std::string & mountError() const
{ return _error; }
, _path(path_r)
{}
/** Dtor. */
- virtual ~MediaUnmountException() throw() {};
+ virtual ~MediaUnmountException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _filename(filename_r)
{}
- virtual ~MediaBadFilenameException() throw() {};
+ virtual ~MediaBadFilenameException() noexcept {}
std::string filename() const { return _filename; }
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
: MediaException()
, _action(action_r)
{}
- virtual ~MediaNotOpenException() throw() {};
+ virtual ~MediaNotOpenException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _url(url_r.asString())
, _filename(filename_r.asString())
{}
- virtual ~MediaFileNotFoundException() throw() {};
+ virtual ~MediaFileNotFoundException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _filename(filename_r.asString())
{}
- virtual ~MediaWriteException() throw() {};
+ virtual ~MediaWriteException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _url(url_r.asString())
{}
- virtual ~MediaNotAttachedException() throw() {};
+ virtual ~MediaNotAttachedException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _url(url_r.asString())
{}
- virtual ~MediaBadAttachPointException() throw() {};
+ virtual ~MediaBadAttachPointException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _url(url_r.asString())
{}
- virtual ~MediaCurlInitException() throw() {};
+ virtual ~MediaCurlInitException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _url(url_r.asString())
, _message(message_r)
{}
- virtual ~MediaSystemException() throw() {};
+ virtual ~MediaSystemException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _url(url_r.asString())
, _path(path_r.asString())
{}
- virtual ~MediaNotAFileException() throw() {};
+ virtual ~MediaNotAFileException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _url(url_r.asString())
, _path(path_r.asString())
{}
- virtual ~MediaNotADirException() throw() {};
+ virtual ~MediaNotADirException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _url(url_r.asString())
, _msg(msg_r)
{}
- virtual ~MediaBadUrlException() throw() {};
+ virtual ~MediaBadUrlException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
std::string _url;
MediaBadUrlEmptyHostException(const Url & url_r)
: MediaBadUrlException(url_r)
{}
- virtual ~MediaBadUrlEmptyHostException() throw() {};
+ virtual ~MediaBadUrlEmptyHostException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
MediaBadUrlEmptyFilesystemException(const Url & url_r)
: MediaBadUrlException(url_r)
{}
- virtual ~MediaBadUrlEmptyFilesystemException() throw() {};
+ virtual ~MediaBadUrlEmptyFilesystemException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
MediaBadUrlEmptyDestinationException(const Url & url_r)
: MediaBadUrlException(url_r)
{}
- virtual ~MediaBadUrlEmptyDestinationException() throw() {};
+ virtual ~MediaBadUrlEmptyDestinationException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
MediaUnsupportedUrlSchemeException(const Url & url_r)
: MediaBadUrlException(url_r)
{}
- virtual ~MediaUnsupportedUrlSchemeException() throw() {};
+ virtual ~MediaUnsupportedUrlSchemeException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
: MediaException()
, _url(url_r.asString())
{}
- virtual ~MediaNotSupportedException() throw() {};
+ virtual ~MediaNotSupportedException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
std::string _url;
, _err(err_r)
, _msg(msg_r)
{}
- virtual ~MediaCurlException() throw() {};
+ virtual ~MediaCurlException() noexcept {}
+ std::string errstr() const { return _err; }
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
std::string _url;
, _url(url_r.asString())
, _msg(msg_r)
{}
- virtual ~MediaCurlSetOptException() throw() {};
+ virtual ~MediaCurlSetOptException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
std::string _url;
: MediaException()
, _url(url_r.asString())
{}
- virtual ~MediaNotDesiredException() throw() {};
+ virtual ~MediaNotDesiredException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException()
, _name(name)
{}
- virtual ~MediaIsSharedException() throw() {};
+ virtual ~MediaIsSharedException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
: MediaException("Can't eject media")
, _name(name)
{}
- virtual ~MediaNotEjectedException() throw() {};
+ virtual ~MediaNotEjectedException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
, _hint(hint_r)
{}
- virtual ~MediaUnauthorizedException() throw() {};
+ virtual ~MediaUnauthorizedException() noexcept {}
const Url & url() const { return _url; }
const std::string & err() const { return _err; }
: MediaException(msg)
, _url(url_r.asString()), _msg(msg)
{}
- virtual ~MediaForbiddenException() throw() {};
+ virtual ~MediaForbiddenException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaTimeoutException : public MediaException
+ {
+ public:
+ MediaTimeoutException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaTimeoutException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaFileSizeExceededException : public MediaException
+ {
+ public:
+ MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString())
+ , _msg(msg)
+ , _expectedFileSize(cnt_r)
+ {}
+ virtual ~MediaFileSizeExceededException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ ByteCount _expectedFileSize;
+ };
+
+ /** For HTTP 503 and similar. */
+ class MediaTemporaryProblemException : public MediaException
+ {
+ public:
+ MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaTemporaryProblemException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaBadCAException : public MediaException
+ {
+ public:
+ MediaBadCAException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaBadCAException() noexcept {}
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
std::string _url;