MediaException.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
00013 #define ZYPP_MEDIA_MEDIAEXCEPTION_H
00014 
00015 #include <iosfwd>
00016 
00017 #include <string>
00018 
00019 #include "zypp/base/Exception.h"
00020 #include "zypp/Pathname.h"
00021 #include "zypp/Url.h"
00022 
00024 namespace zypp
00025 { 
00026   namespace media {
00028     //
00029     //  CLASS NAME : MediaException
00033     class MediaException : public Exception
00034     {
00035     public:
00039       MediaException()
00040       : Exception( "Media Exception" )
00041       {}
00045       MediaException( const std::string & msg_r )
00046       : Exception( msg_r )
00047       {}
00049       virtual ~MediaException() throw() {};
00050     };
00051 
00052     class MediaMountException : public MediaException
00053     {
00054     public:
00058       MediaMountException( const std::string & error_r,
00059                            const std::string & source_r,
00060                            const std::string & target_r )
00061       : MediaException()
00062       , _error(error_r)
00063       , _source(source_r)
00064       , _target(target_r)
00065       {}
00067       virtual ~MediaMountException() throw() {};
00068     protected:
00069       virtual std::ostream & dumpOn( std::ostream & str ) const;
00070     private:
00071       std::string _error;
00072       std::string _source;
00073       std::string _target;
00074     };
00075 
00076     class MediaUnmountException : public MediaException
00077     {
00078     public:
00082       MediaUnmountException( const std::string & error_r,
00083                              const std::string & path_r )
00084       : MediaException()
00085       , _error(error_r)
00086       , _path(path_r)
00087       {}
00089       virtual ~MediaUnmountException() throw() {};
00090     protected:
00091       virtual std::ostream & dumpOn( std::ostream & str ) const;
00092     private:
00093       std::string _error;
00094       std::string _path;
00095     };
00096 
00097     class MediaBadFilenameException : public MediaException
00098     {
00099     public:
00100       MediaBadFilenameException(const std::string & filename_r)
00101       : MediaException()
00102       , _filename(filename_r)
00103       {}
00104       virtual ~MediaBadFilenameException() throw() {};
00105       std::string filename() const { return _filename; }
00106     protected:
00107       virtual std::ostream & dumpOn( std::ostream & str ) const;
00108     private:
00109       std::string _filename;
00110     };
00111 
00112     class MediaNotOpenException : public MediaException
00113     {
00114     public:
00115       MediaNotOpenException(const std::string & action_r)
00116       : MediaException()
00117       , _action(action_r)
00118       {}
00119       virtual ~MediaNotOpenException() throw() {};
00120     protected:
00121       virtual std::ostream & dumpOn( std::ostream & str ) const;
00122     private:
00123       std::string _action;
00124     };
00125 
00126     class MediaFileNotFoundException : public MediaException
00127     {
00128     public:
00129       MediaFileNotFoundException(const Url & url_r,
00130                                  const Pathname & filename_r)
00131       : MediaException()
00132       , _url(url_r.asString())
00133       , _filename(filename_r.asString())
00134       {}
00135       virtual ~MediaFileNotFoundException() throw() {};
00136     protected:
00137       virtual std::ostream & dumpOn( std::ostream & str ) const;
00138     private:
00139       std::string _url;
00140       std::string _filename;
00141     };
00142 
00143     class MediaWriteException : public MediaException
00144     {
00145     public:
00146       MediaWriteException(const Pathname & filename_r)
00147       : MediaException()
00148       , _filename(filename_r.asString())
00149       {}
00150       virtual ~MediaWriteException() throw() {};
00151     protected:
00152       virtual std::ostream & dumpOn( std::ostream & str ) const;
00153     private:
00154       std::string _filename;
00155     };
00156 
00157     class MediaNotAttachedException : public MediaException
00158     {
00159     public:
00160       MediaNotAttachedException(const Url & url_r)
00161       : MediaException()
00162       , _url(url_r.asString())
00163       {}
00164       virtual ~MediaNotAttachedException() throw() {};
00165     protected:
00166       virtual std::ostream & dumpOn( std::ostream & str ) const;
00167     private:
00168       std::string _url;
00169     };
00170 
00171     class MediaBadAttachPointException : public MediaException
00172     {
00173     public:
00174       MediaBadAttachPointException(const Url & url_r)
00175       : MediaException()
00176       , _url(url_r.asString())
00177       {}
00178       virtual ~MediaBadAttachPointException() throw() {};
00179     protected:
00180       virtual std::ostream & dumpOn( std::ostream & str ) const;
00181     private:
00182       std::string _url;
00183     };
00184 
00185     class MediaCurlInitException : public MediaException
00186     {
00187     public:
00188       MediaCurlInitException(const Url & url_r)
00189       : MediaException()
00190       , _url(url_r.asString())
00191       {}
00192       virtual ~MediaCurlInitException() throw() {};
00193     protected:
00194       virtual std::ostream & dumpOn( std::ostream & str ) const;
00195     private:
00196       std::string _url;
00197     };
00198 
00199     class MediaSystemException : public MediaException
00200     {
00201     public:
00202       MediaSystemException(const Url & url_r,
00203                            const std::string & message_r)
00204       : MediaException()
00205       , _url(url_r.asString())
00206       , _message(message_r)
00207       {}
00208       virtual ~MediaSystemException() throw() {};
00209     protected:
00210       virtual std::ostream & dumpOn( std::ostream & str ) const;
00211     private:
00212       std::string _url;
00213       std::string _message;
00214     };
00215 
00216     class MediaNotAFileException : public MediaException
00217     {
00218     public:
00219       MediaNotAFileException(const Url & url_r,
00220                              const Pathname & path_r)
00221       : MediaException()
00222       , _url(url_r.asString())
00223       , _path(path_r.asString())
00224       {}
00225       virtual ~MediaNotAFileException() throw() {};
00226     protected:
00227       virtual std::ostream & dumpOn( std::ostream & str ) const;
00228     private:
00229       std::string _url;
00230       std::string _path;
00231     };
00232 
00233     class MediaNotADirException : public MediaException
00234     {
00235     public:
00236       MediaNotADirException(const Url & url_r,
00237                             const Pathname & path_r)
00238       : MediaException()
00239       , _url(url_r.asString())
00240       , _path(path_r.asString())
00241       {}
00242       virtual ~MediaNotADirException() throw() {};
00243     protected:
00244       virtual std::ostream & dumpOn( std::ostream & str ) const;
00245     private:
00246       std::string _url;
00247       std::string _path;
00248     };
00249 
00250     class MediaBadUrlException : public MediaException
00251     {
00252     public:
00253       MediaBadUrlException(const Url & url_r,
00254                            const std::string &msg_r = std::string())
00255       : MediaException()
00256       , _url(url_r.asString())
00257       , _msg(msg_r)
00258       {}
00259       virtual ~MediaBadUrlException() throw() {};
00260     protected:
00261       virtual std::ostream & dumpOn( std::ostream & str ) const;
00262       std::string _url;
00263       std::string _msg;
00264     };
00265 
00266     class MediaBadUrlEmptyHostException : public MediaBadUrlException
00267     {
00268     public:
00269       MediaBadUrlEmptyHostException(const Url & url_r)
00270       : MediaBadUrlException(url_r)
00271       {}
00272       virtual ~MediaBadUrlEmptyHostException() throw() {};
00273     protected:
00274       virtual std::ostream & dumpOn( std::ostream & str ) const;
00275     };
00276 
00277     class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
00278     {
00279     public:
00280       MediaBadUrlEmptyFilesystemException(const Url & url_r)
00281       : MediaBadUrlException(url_r)
00282       {}
00283       virtual ~MediaBadUrlEmptyFilesystemException() throw() {};
00284     protected:
00285       virtual std::ostream & dumpOn( std::ostream & str ) const;
00286     };
00287 
00288     class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
00289     {
00290     public:
00291       MediaBadUrlEmptyDestinationException(const Url & url_r)
00292       : MediaBadUrlException(url_r)
00293       {}
00294       virtual ~MediaBadUrlEmptyDestinationException() throw() {};
00295     protected:
00296       virtual std::ostream & dumpOn( std::ostream & str ) const;
00297     };
00298 
00299     class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
00300     {
00301     public:
00302       MediaUnsupportedUrlSchemeException(const Url & url_r)
00303       : MediaBadUrlException(url_r)
00304       {}
00305       virtual ~MediaUnsupportedUrlSchemeException() throw() {};
00306     protected:
00307       virtual std::ostream & dumpOn( std::ostream & str ) const;
00308     };
00309 
00310     class MediaNotSupportedException : public MediaException
00311     {
00312     public:
00313       MediaNotSupportedException(const Url & url_r)
00314       : MediaException()
00315       , _url(url_r.asString())
00316       {}
00317       virtual ~MediaNotSupportedException() throw() {};
00318     protected:
00319       virtual std::ostream & dumpOn( std::ostream & str ) const;
00320       std::string _url;
00321     };
00322 
00323     class MediaCurlException : public MediaException
00324     {
00325     public:
00326       MediaCurlException(const Url & url_r,
00327                          const std::string & err_r,
00328                          const std::string & msg_r)
00329       : MediaException()
00330       , _url(url_r.asString())
00331       , _err(err_r)
00332       , _msg(msg_r)
00333       {}
00334       virtual ~MediaCurlException() throw() {};
00335     protected:
00336       virtual std::ostream & dumpOn( std::ostream & str ) const;
00337       std::string _url;
00338       std::string _err;
00339       std::string _msg;
00340     };
00341 
00342     class MediaCurlSetOptException : public MediaException
00343     {
00344     public:
00345       MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
00346       : MediaException()
00347       , _url(url_r.asString())
00348       , _msg(msg_r)
00349       {}
00350       virtual ~MediaCurlSetOptException() throw() {};
00351     protected:
00352       virtual std::ostream & dumpOn( std::ostream & str ) const;
00353       std::string _url;
00354       std::string _msg;
00355     };
00356 
00357     class MediaNotDesiredException : public MediaException
00358     {
00359     public:
00360       MediaNotDesiredException(const Url & url_r)
00361       : MediaException()
00362       , _url(url_r.asString())
00363       {}
00364       virtual ~MediaNotDesiredException() throw() {};
00365     protected:
00366       virtual std::ostream & dumpOn( std::ostream & str ) const;
00367     private:
00368       std::string  _url;
00369     };
00370 
00371     class MediaIsSharedException : public MediaException
00372     {
00373     public:
00377       MediaIsSharedException(const std::string &name)
00378       : MediaException()
00379       , _name(name)
00380       {}
00381       virtual ~MediaIsSharedException() throw() {};
00382     protected:
00383       virtual std::ostream & dumpOn( std::ostream & str ) const;
00384     private:
00385       std::string _name;
00386     };
00387 
00388     class MediaNotEjectedException: public MediaException
00389     {
00390     public:
00391       MediaNotEjectedException()
00392       : MediaException("Can't eject any media")
00393       , _name("")
00394       {}
00395 
00396       MediaNotEjectedException(const std::string &name)
00397       : MediaException("Can't eject media")
00398       , _name(name)
00399       {}
00400       virtual ~MediaNotEjectedException() throw() {};
00401     protected:
00402       virtual std::ostream & dumpOn( std::ostream & str ) const;
00403     private:
00404       std::string _name;
00405     };
00406 
00408   } // namespace media
00409 } // namespace zypp
00411 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H

Generated on Thu Jul 6 00:07:21 2006 for zypp by  doxygen 1.4.6