libzypp
10.5.0
|
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 & MediaMetalinkInitException::dumpOn( std::ostream & str) const 00089 { 00090 return str << form( 00091 // TranslatorExplanation: curl is the name of a library, don't translate 00092 _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str()) 00093 << endl; 00094 } 00095 00096 std::ostream & MediaAria2cInitException::dumpOn( std::ostream & str) const 00097 { 00098 return str << form( 00099 // TranslatorExplanation: curl is the name of a library, don't translate 00100 _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str()) 00101 << endl; 00102 } 00103 00104 std::ostream & MediaSystemException::dumpOn( std::ostream & str) const 00105 { 00106 return str << form( 00107 _("System exception '%s' on medium '%s'."), 00108 _message.c_str(), _url.c_str()) << endl; 00109 } 00110 00111 std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const 00112 { 00113 return str << form( 00114 _("Path '%s' on medium '%s' is not a file."), 00115 _path.c_str(), _url.c_str()) 00116 << endl; 00117 } 00118 00119 std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const 00120 { 00121 return str << form( 00122 _("Path '%s' on medium '%s' is not a directory."), 00123 _path.c_str(), _url.c_str()) 00124 << endl; 00125 } 00126 00127 std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const 00128 { 00129 if( _msg.empty()) 00130 { 00131 return str << _("Malformed URI") << ": " << _url << endl; 00132 } 00133 else 00134 { 00135 return str << _msg << ": " << _url << endl; 00136 } 00137 } 00138 00139 std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const 00140 { 00141 return str << _("Empty host name in URI") << ": " << _url << endl; 00142 } 00143 00144 std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const 00145 { 00146 return str << _("Empty filesystem in URI") << ": " << _url << endl; 00147 } 00148 00149 std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const 00150 { 00151 return str << _("Empty destination in URI") << ": " << _url << endl; 00152 } 00153 00154 std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const 00155 { 00156 return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str()) << endl; 00157 } 00158 00159 std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const 00160 { 00161 return str << _("Operation not supported by medium") << ": " << _url << endl; 00162 } 00163 00164 std::ostream & MediaCurlException::dumpOn( std::ostream & str) const 00165 { 00166 // TranslatorExplanation: curl is the name of a library, don't translate 00167 return str << form(_( 00168 "Download (curl) error for '%s':\n" 00169 "Error code: %s\n" 00170 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str()); 00171 } 00172 00173 std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const 00174 { 00175 return str << form( 00176 // TranslatorExplanation: curl is the name of a library, don't translate 00177 _("Error occurred while setting download (curl) options for '%s':"), 00178 _url.c_str()) 00179 << endl << _msg << endl; 00180 } 00181 00182 std::ostream & MediaMetalinkException::dumpOn( std::ostream & str) const 00183 { 00184 // TranslatorExplanation: curl is the name of a library, don't translate 00185 return str << form(_( 00186 "Download (metalink curl) error for '%s':\n" 00187 "Error code: %s\n" 00188 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str()); 00189 } 00190 00191 std::ostream & MediaMetalinkSetOptException::dumpOn( std::ostream & str) const 00192 { 00193 return str << form( 00194 // TranslatorExplanation: curl is the name of a library, don't translate 00195 _("Error occurred while setting download (metalink curl) options for '%s':"), 00196 _url.c_str()) 00197 << endl << _msg << endl; 00198 } 00199 00200 std::ostream & MediaAria2cException::dumpOn( std::ostream & str) const 00201 { 00202 // TranslatorExplanation: curl is the name of a library, don't translate 00203 return str << form(_( 00204 "Download (metalink curl) error for '%s':\n" 00205 "Error code: %s\n" 00206 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str()); 00207 } 00208 00209 std::ostream & MediaAria2cSetOptException::dumpOn( std::ostream & str) const 00210 { 00211 return str << form( 00212 // TranslatorExplanation: curl is the name of a library, don't translate 00213 _("Error occurred while setting download (metalink curl) options for '%s':"), 00214 _url.c_str()) 00215 << endl << _msg << endl; 00216 } 00217 00218 std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const 00219 { 00220 return str << form( 00221 _("Media source '%s' does not contain the desired medium"), _url.c_str()) 00222 << endl; 00223 } 00224 00225 std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const 00226 { 00227 return str << form(_("Medium '%s' is in use by another instance"), _name.c_str()) 00228 << endl; 00229 } 00230 00231 std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const 00232 { 00233 if( _name.empty()) 00234 return str << _("Cannot eject any media") << endl; 00235 else 00236 return str << form(_("Cannot eject media '%s'"), _name.c_str()) << endl; 00237 } 00238 00239 std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const 00240 { 00241 str << msg(); 00242 if( !_url.asString().empty()) 00243 str << " (" << _url << ")"; 00244 if( !_err.empty()) 00245 str << ": " << _err; 00246 return str; 00247 } 00248 00249 std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const 00250 { 00251 str << form(_("Permission to access '%s' denied."), _url.c_str()) << endl; 00252 if ( !_msg.empty() ) 00253 str << endl << _msg << endl; 00254 return str; 00255 } 00256 00257 std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const 00258 { 00259 str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str()) << endl; 00260 if ( !_msg.empty() ) 00261 str << endl << _msg << endl; 00262 return str; 00263 } 00264 00265 std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const 00266 { 00267 str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str()) << endl; 00268 if ( !_msg.empty() ) 00269 str << endl << _msg << endl; 00270 return str; 00271 } 00272 00273 std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const 00274 { 00275 str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str()) << endl; 00276 if ( !_msg.empty() ) 00277 str << endl << _msg << endl; 00278 return str; 00279 } 00280 00281 std::ostream & MediaNoLoopDeviceException::dumpOn( std::ostream & str ) const 00282 { 00283 str << form(_("Cannot find available loop device to mount the image file from '%s'"), _url.c_str()) << endl; 00284 if ( !_msg.empty() ) 00285 str << endl << _msg << endl; 00286 return str; 00287 } 00288 00290 } // namespace media 00291 } // namespace zypp