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:
00055       MediaMountException()
00056       : MediaException( "Media Mount Exception" )
00057       {}
00058 
00062       MediaMountException( const std::string & error_r,
00063                            const std::string & source_r,
00064                            const std::string & target_r,
00065                            const std::string & cmdout_r="")
00066       : MediaException()
00067       , _error(error_r)
00068       , _source(source_r)
00069       , _target(target_r)
00070       , _cmdout(cmdout_r)
00071       {}
00073       virtual ~MediaMountException() throw() {};
00074 
00075       const std::string & mountError() const
00076       { return _error;  }
00077       const std::string & mountSource() const
00078       { return _source; }
00079       const std::string & mountTarget() const
00080       { return _target; }
00081       const std::string & mountOutput() const
00082       { return _cmdout; }
00083 
00084     protected:
00085       virtual std::ostream & dumpOn( std::ostream & str ) const;
00086     private:
00087       std::string _error;
00088       std::string _source;
00089       std::string _target;
00090       std::string _cmdout;
00091     };
00092 
00093     class MediaUnmountException : public MediaException
00094     {
00095     public:
00099       MediaUnmountException( const std::string & error_r,
00100                              const std::string & path_r )
00101       : MediaException()
00102       , _error(error_r)
00103       , _path(path_r)
00104       {}
00106       virtual ~MediaUnmountException() throw() {};
00107     protected:
00108       virtual std::ostream & dumpOn( std::ostream & str ) const;
00109     private:
00110       std::string _error;
00111       std::string _path;
00112     };
00113 
00114     class MediaBadFilenameException : public MediaException
00115     {
00116     public:
00117       MediaBadFilenameException(const std::string & filename_r)
00118       : MediaException()
00119       , _filename(filename_r)
00120       {}
00121       virtual ~MediaBadFilenameException() throw() {};
00122       std::string filename() const { return _filename; }
00123     protected:
00124       virtual std::ostream & dumpOn( std::ostream & str ) const;
00125     private:
00126       std::string _filename;
00127     };
00128 
00129     class MediaNotOpenException : public MediaException
00130     {
00131     public:
00132       MediaNotOpenException(const std::string & action_r)
00133       : MediaException()
00134       , _action(action_r)
00135       {}
00136       virtual ~MediaNotOpenException() throw() {};
00137     protected:
00138       virtual std::ostream & dumpOn( std::ostream & str ) const;
00139     private:
00140       std::string _action;
00141     };
00142 
00143     class MediaFileNotFoundException : public MediaException
00144     {
00145     public:
00146       MediaFileNotFoundException(const Url & url_r,
00147                                  const Pathname & filename_r)
00148       : MediaException()
00149       , _url(url_r.asString())
00150       , _filename(filename_r.asString())
00151       {}
00152       virtual ~MediaFileNotFoundException() throw() {};
00153     protected:
00154       virtual std::ostream & dumpOn( std::ostream & str ) const;
00155     private:
00156       std::string _url;
00157       std::string _filename;
00158     };
00159 
00160     class MediaWriteException : public MediaException
00161     {
00162     public:
00163       MediaWriteException(const Pathname & filename_r)
00164       : MediaException()
00165       , _filename(filename_r.asString())
00166       {}
00167       virtual ~MediaWriteException() throw() {};
00168     protected:
00169       virtual std::ostream & dumpOn( std::ostream & str ) const;
00170     private:
00171       std::string _filename;
00172     };
00173 
00174     class MediaNotAttachedException : public MediaException
00175     {
00176     public:
00177       MediaNotAttachedException(const Url & url_r)
00178       : MediaException()
00179       , _url(url_r.asString())
00180       {}
00181       virtual ~MediaNotAttachedException() throw() {};
00182     protected:
00183       virtual std::ostream & dumpOn( std::ostream & str ) const;
00184     private:
00185       std::string _url;
00186     };
00187 
00188     class MediaBadAttachPointException : public MediaException
00189     {
00190     public:
00191       MediaBadAttachPointException(const Url & url_r)
00192       : MediaException()
00193       , _url(url_r.asString())
00194       {}
00195       virtual ~MediaBadAttachPointException() throw() {};
00196     protected:
00197       virtual std::ostream & dumpOn( std::ostream & str ) const;
00198     private:
00199       std::string _url;
00200     };
00201 
00202     class MediaCurlInitException : public MediaException
00203     {
00204     public:
00205       MediaCurlInitException(const Url & url_r)
00206       : MediaException()
00207       , _url(url_r.asString())
00208       {}
00209       virtual ~MediaCurlInitException() throw() {};
00210     protected:
00211       virtual std::ostream & dumpOn( std::ostream & str ) const;
00212     private:
00213       std::string _url;
00214     };
00215 
00216     class MediaSystemException : public MediaException
00217     {
00218     public:
00219       MediaSystemException(const Url & url_r,
00220                            const std::string & message_r)
00221       : MediaException()
00222       , _url(url_r.asString())
00223       , _message(message_r)
00224       {}
00225       virtual ~MediaSystemException() throw() {};
00226     protected:
00227       virtual std::ostream & dumpOn( std::ostream & str ) const;
00228     private:
00229       std::string _url;
00230       std::string _message;
00231     };
00232 
00233     class MediaNotAFileException : public MediaException
00234     {
00235     public:
00236       MediaNotAFileException(const Url & url_r,
00237                              const Pathname & path_r)
00238       : MediaException()
00239       , _url(url_r.asString())
00240       , _path(path_r.asString())
00241       {}
00242       virtual ~MediaNotAFileException() 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 MediaNotADirException : public MediaException
00251     {
00252     public:
00253       MediaNotADirException(const Url & url_r,
00254                             const Pathname & path_r)
00255       : MediaException()
00256       , _url(url_r.asString())
00257       , _path(path_r.asString())
00258       {}
00259       virtual ~MediaNotADirException() throw() {};
00260     protected:
00261       virtual std::ostream & dumpOn( std::ostream & str ) const;
00262     private:
00263       std::string _url;
00264       std::string _path;
00265     };
00266 
00267     class MediaBadUrlException : public MediaException
00268     {
00269     public:
00270       MediaBadUrlException(const Url & url_r,
00271                            const std::string &msg_r = std::string())
00272       : MediaException()
00273       , _url(url_r.asString())
00274       , _msg(msg_r)
00275       {}
00276       virtual ~MediaBadUrlException() throw() {};
00277     protected:
00278       virtual std::ostream & dumpOn( std::ostream & str ) const;
00279       std::string _url;
00280       std::string _msg;
00281     };
00282 
00283     class MediaBadUrlEmptyHostException : public MediaBadUrlException
00284     {
00285     public:
00286       MediaBadUrlEmptyHostException(const Url & url_r)
00287       : MediaBadUrlException(url_r)
00288       {}
00289       virtual ~MediaBadUrlEmptyHostException() throw() {};
00290     protected:
00291       virtual std::ostream & dumpOn( std::ostream & str ) const;
00292     };
00293 
00294     class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
00295     {
00296     public:
00297       MediaBadUrlEmptyFilesystemException(const Url & url_r)
00298       : MediaBadUrlException(url_r)
00299       {}
00300       virtual ~MediaBadUrlEmptyFilesystemException() throw() {};
00301     protected:
00302       virtual std::ostream & dumpOn( std::ostream & str ) const;
00303     };
00304 
00305     class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
00306     {
00307     public:
00308       MediaBadUrlEmptyDestinationException(const Url & url_r)
00309       : MediaBadUrlException(url_r)
00310       {}
00311       virtual ~MediaBadUrlEmptyDestinationException() throw() {};
00312     protected:
00313       virtual std::ostream & dumpOn( std::ostream & str ) const;
00314     };
00315 
00316     class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
00317     {
00318     public:
00319       MediaUnsupportedUrlSchemeException(const Url & url_r)
00320       : MediaBadUrlException(url_r)
00321       {}
00322       virtual ~MediaUnsupportedUrlSchemeException() throw() {};
00323     protected:
00324       virtual std::ostream & dumpOn( std::ostream & str ) const;
00325     };
00326 
00327     class MediaNotSupportedException : public MediaException
00328     {
00329     public:
00330       MediaNotSupportedException(const Url & url_r)
00331       : MediaException()
00332       , _url(url_r.asString())
00333       {}
00334       virtual ~MediaNotSupportedException() throw() {};
00335     protected:
00336       virtual std::ostream & dumpOn( std::ostream & str ) const;
00337       std::string _url;
00338     };
00339 
00340     class MediaCurlException : public MediaException
00341     {
00342     public:
00343       MediaCurlException(const Url & url_r,
00344                          const std::string & err_r,
00345                          const std::string & msg_r)
00346       : MediaException()
00347       , _url(url_r.asString())
00348       , _err(err_r)
00349       , _msg(msg_r)
00350       {}
00351       virtual ~MediaCurlException() throw() {};
00352     protected:
00353       virtual std::ostream & dumpOn( std::ostream & str ) const;
00354       std::string _url;
00355       std::string _err;
00356       std::string _msg;
00357     };
00358 
00359     class MediaCurlSetOptException : public MediaException
00360     {
00361     public:
00362       MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
00363       : MediaException()
00364       , _url(url_r.asString())
00365       , _msg(msg_r)
00366       {}
00367       virtual ~MediaCurlSetOptException() throw() {};
00368     protected:
00369       virtual std::ostream & dumpOn( std::ostream & str ) const;
00370       std::string _url;
00371       std::string _msg;
00372     };
00373 
00374     class MediaNotDesiredException : public MediaException
00375     {
00376     public:
00377       MediaNotDesiredException(const Url & url_r)
00378       : MediaException()
00379       , _url(url_r.asString())
00380       {}
00381       virtual ~MediaNotDesiredException() throw() {};
00382     protected:
00383       virtual std::ostream & dumpOn( std::ostream & str ) const;
00384     private:
00385       std::string  _url;
00386     };
00387 
00388     class MediaIsSharedException : public MediaException
00389     {
00390     public:
00394       MediaIsSharedException(const std::string &name)
00395       : MediaException()
00396       , _name(name)
00397       {}
00398       virtual ~MediaIsSharedException() throw() {};
00399     protected:
00400       virtual std::ostream & dumpOn( std::ostream & str ) const;
00401     private:
00402       std::string _name;
00403     };
00404 
00405     class MediaNotEjectedException: public MediaException
00406     {
00407     public:
00408       MediaNotEjectedException()
00409       : MediaException("Can't eject any media")
00410       , _name("")
00411       {}
00412 
00413       MediaNotEjectedException(const std::string &name)
00414       : MediaException("Can't eject media")
00415       , _name(name)
00416       {}
00417       virtual ~MediaNotEjectedException() throw() {};
00418     protected:
00419       virtual std::ostream & dumpOn( std::ostream & str ) const;
00420     private:
00421       std::string _name;
00422     };
00423 
00424     class MediaUnauthorizedException: public MediaException
00425     {
00426     public:
00427       MediaUnauthorizedException()
00428       : MediaException("Unauthorized media access")
00429       , _url("")
00430       , _err("")
00431       , _hint("")
00432       {}
00433 
00434       MediaUnauthorizedException(const Url         &url_r,
00435                                  const std::string &msg_r,
00436                                  const std::string &err_r,
00437                                  const std::string &hint_r)
00438       : MediaException(msg_r)
00439       , _url(url_r)
00440       , _err(err_r)
00441       , _hint(hint_r)
00442       {}
00443 
00444       virtual ~MediaUnauthorizedException() throw() {};
00445 
00446       const Url         & url()  const { return _url;  }
00447       const std::string & err()  const { return _err;  }
00449       const std::string & hint() const { return _hint; }
00450 
00451     protected:
00452       virtual std::ostream & dumpOn( std::ostream & str ) const;
00453     private:
00454       Url         _url;
00455       std::string _err;
00456       std::string _hint;
00457     };
00458 
00460   } // namespace media
00461 } // namespace zypp
00463 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H

Generated on Tue Sep 25 19:23:02 2007 for libzypp by  doxygen 1.5.3