MediaException.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #include <iostream>
00014 
00015 #include "zypp/base/String.h"
00016 #include "zypp/base/Gettext.h"
00017 
00018 #include "zypp/media/MediaException.h"
00019 
00020 using namespace std;
00021 using zypp::str::form;
00022 
00024 namespace zypp
00025 { 
00026   namespace media {
00028 
00029     std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
00030     {
00031       str << form(_("Failed to mount %s on %s"), _source.c_str(), _target.c_str());
00032       if( !_cmdout.empty())
00033         str << ": " << _error << " (" << _cmdout << ")" << endl;
00034       else
00035         str << ": " << _error << endl;
00036       return str;
00037     }
00038 
00039     std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
00040     {
00041       return str << form(_("Failed to unmount %s"), _path.c_str())
00042         << " : " << _error << endl;
00043     }
00044 
00045     std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
00046     {
00047       return str << form(_("Bad file name: %s"), _filename.c_str()) << endl;
00048     }
00049 
00050     std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
00051     {
00052       return str << form(
00053         _("Medium not opened when trying to perform action '%s'."), _action.c_str())
00054        << endl;
00055     }
00056 
00057     std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
00058     {
00059       return str << form(
00060         _("File '%s' not found on medium '%s'"),
00061         _filename.c_str(), _url.c_str())
00062         << endl;
00063     }
00064 
00065     std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
00066     {
00067       return str << form(_("Cannot write file '%s'."), _filename.c_str()) << endl;
00068     }
00069 
00070     std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
00071     {
00072       return str << _("Medium not attached") << ": " << _url << endl;
00073     }
00074 
00075     std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
00076     {
00077       return str << _("Bad media attach point") << ": " << _url << endl;
00078     }
00079 
00080     std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
00081     {
00082       return str << form(
00083         // TranslatorExplanation: curl is the name of a library, don't translate
00084         _("Download (curl) initialization failed for '%s'"), _url.c_str())
00085         << endl;
00086     }
00087 
00088     std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
00089     {
00090       return str << form(
00091         _("System exception '%s' on medium '%s'."),
00092         _message.c_str(), _url.c_str()) << endl;
00093     }
00094 
00095     std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
00096     {
00097       return str << form(
00098         _("Path '%s' on medium '%s' is not a file."),
00099         _path.c_str(), _url.c_str())
00100         << endl;
00101     }
00102 
00103     std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
00104     {
00105       return str << form(
00106         _("Path '%s' on medium '%s' is not a directory."),
00107         _path.c_str(), _url.c_str())
00108         << endl;
00109     }
00110 
00111     std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
00112     {
00113       if( _msg.empty())
00114       {
00115         return str << _("Malformed URI") << ": " << _url << endl;
00116       }
00117       else
00118       {
00119         return str << _msg << ": " << _url << endl;
00120       }
00121     }
00122 
00123     std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
00124     {
00125       return str << _("Empty host name in URI") << ": " << _url << endl;
00126     }
00127 
00128     std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
00129     {
00130       return str << _("Empty filesystem in URI") << ": " << _url << endl;
00131     }
00132 
00133     std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
00134     {
00135       return str << _("Empty destination in URI") << ": " << _url << endl;
00136     }
00137 
00138     std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
00139     {
00140       return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str()) << endl;
00141     }
00142 
00143     std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
00144     {
00145       return str << _("Operation not supported by medium") << ": " << _url << endl;
00146     }
00147 
00148     std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
00149     {
00150       // TranslatorExplanation: curl is the name of a library, don't translate
00151       return str << form(_(
00152         "Download (curl) error for '%s':\n"
00153         "Error code: %s\n"
00154         "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
00155     }
00156 
00157     std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
00158     {
00159       return str << form(
00160         // TranslatorExplanation: curl is the name of a library, don't translate
00161         _("Error occurred while setting download (curl) options for '%s':"),
00162         _url.c_str())
00163        << endl << _msg << endl;
00164     }
00165 
00166     std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
00167     {
00168       return str << form(
00169         _("Media source '%s' does not contain the desired medium"), _url.c_str())
00170         << endl;
00171     }
00172 
00173     std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
00174     {
00175       return str << form(_("Medium '%s' is in use by another instance"), _name.c_str())
00176                  << endl;
00177     }
00178 
00179     std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
00180     {
00181       if( _name.empty())
00182         return str << _("Cannot eject any media") << endl;
00183       else
00184         return str << form(_("Cannot eject media '%s'"), _name.c_str()) << endl;
00185     }
00186 
00187     std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
00188     {
00189       if (_msg.empty())
00190         return str << form(_("Permission to access '%s' denied."), _url.c_str()) << endl;
00191       return str << _msg << endl;
00192     }
00193 
00195   } // namespace media
00196 } // namespace zypp

Generated on Thu Apr 24 02:24:49 2008 for zypp by  doxygen 1.4.6