1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaException.cc
15 #include "zypp/base/String.h"
16 #include "zypp/base/Gettext.h"
18 #include "zypp/media/MediaException.h"
21 using zypp::str::form;
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
27 /////////////////////////////////////////////////////////////////
29 std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
31 str << form(_("Failed to mount %s on %s"), _source.c_str(), _target.c_str());
33 str << ": " << _error << " (" << _cmdout << ")" << endl;
35 str << ": " << _error << endl;
39 std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
41 return str << form(_("Failed to unmount %s"), _path.c_str())
42 << " : " << _error << endl;
45 std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
47 return str << form(_("Bad file name: %s"), _filename.c_str()) << endl;
50 std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
53 _("Medium not opened when trying to perform action '%s'."), _action.c_str())
57 std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
60 _("File '%s' not found on medium '%s'"),
61 _filename.c_str(), _url.c_str())
65 std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
67 return str << form(_("Cannot write file '%s'."), _filename.c_str()) << endl;
70 std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
72 return str << _("Medium not attached") << ": " << _url << endl;
75 std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
77 return str << _("Bad media attach point") << ": " << _url << endl;
80 std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
83 // TranslatorExplanation: curl is the name of a library, don't translate
84 _("Download (curl) initialization failed for '%s'"), _url.c_str())
88 std::ostream & MediaMetalinkInitException::dumpOn( std::ostream & str) const
91 // TranslatorExplanation: curl is the name of a library, don't translate
92 _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
96 std::ostream & MediaAria2cInitException::dumpOn( std::ostream & str) const
99 // TranslatorExplanation: curl is the name of a library, don't translate
100 _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
104 std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
107 _("System exception '%s' on medium '%s'."),
108 _message.c_str(), _url.c_str()) << endl;
111 std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
114 _("Path '%s' on medium '%s' is not a file."),
115 _path.c_str(), _url.c_str())
119 std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
122 _("Path '%s' on medium '%s' is not a directory."),
123 _path.c_str(), _url.c_str())
127 std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
131 return str << _("Malformed URI") << ": " << _url << endl;
135 return str << _msg << ": " << _url << endl;
139 std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
141 return str << _("Empty host name in URI") << ": " << _url << endl;
144 std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
146 return str << _("Empty filesystem in URI") << ": " << _url << endl;
149 std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
151 return str << _("Empty destination in URI") << ": " << _url << endl;
154 std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
156 return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str()) << endl;
159 std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
161 return str << _("Operation not supported by medium") << ": " << _url << endl;
164 std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
166 // TranslatorExplanation: curl is the name of a library, don't translate
167 return str << form(_(
168 "Download (curl) error for '%s':\n"
170 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
173 std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
176 // TranslatorExplanation: curl is the name of a library, don't translate
177 _("Error occurred while setting download (curl) options for '%s':"),
179 << endl << _msg << endl;
182 std::ostream & MediaMetalinkException::dumpOn( std::ostream & str) const
184 // TranslatorExplanation: curl is the name of a library, don't translate
185 return str << form(_(
186 "Download (metalink curl) error for '%s':\n"
188 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
191 std::ostream & MediaMetalinkSetOptException::dumpOn( std::ostream & str) const
194 // TranslatorExplanation: curl is the name of a library, don't translate
195 _("Error occurred while setting download (metalink curl) options for '%s':"),
197 << endl << _msg << endl;
200 std::ostream & MediaAria2cException::dumpOn( std::ostream & str) const
202 // TranslatorExplanation: curl is the name of a library, don't translate
203 return str << form(_(
204 "Download (metalink curl) error for '%s':\n"
206 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
209 std::ostream & MediaAria2cSetOptException::dumpOn( std::ostream & str) const
212 // TranslatorExplanation: curl is the name of a library, don't translate
213 _("Error occurred while setting download (metalink curl) options for '%s':"),
215 << endl << _msg << endl;
218 std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
221 _("Media source '%s' does not contain the desired medium"), _url.c_str())
225 std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
227 return str << form(_("Medium '%s' is in use by another instance"), _name.c_str())
231 std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
234 return str << _("Cannot eject any media") << endl;
236 return str << form(_("Cannot eject media '%s'"), _name.c_str()) << endl;
239 std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
242 if( !_url.asString().empty())
243 str << " (" << _url << ")";
249 std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
252 return str << form(_("Permission to access '%s' denied."), _url.c_str()) << endl;
253 return str << _msg << endl;
256 std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
259 return str << form(_("Timeout exceeded when access '%s'."), _url.c_str()) << endl;
260 return str << _msg << endl;
263 std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
266 return str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str()) << endl;
267 return str << _msg << endl;
270 std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
273 return str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str()) << endl;
274 return str << _msg << endl;
277 std::ostream & MediaNoLoopDeviceException::dumpOn( std::ostream & str ) const
280 return str << form(_("Cannot find available loop device to mount the image file from '%s'"), _url.c_str()) << endl;
281 return str << msg() << endl;
284 /////////////////////////////////////////////////////////////////
287 ///////////////////////////////////////////////////////////////////