libzypp  11.13.5
MediaException.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 
15 #include "zypp/base/String.h"
16 #include "zypp/base/Gettext.h"
17 
19 
20 using namespace std;
21 using zypp::str::form;
22 
24 namespace zypp
25 {
26  namespace media {
28 
29  std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
30  {
31  str << form(_("Failed to mount %s on %s"), _source.c_str(), _target.c_str());
32  if( !_cmdout.empty())
33  str << ": " << _error << " (" << _cmdout << ")" << endl;
34  else
35  str << ": " << _error << endl;
36  return str;
37  }
38 
39  std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
40  {
41  return str << form(_("Failed to unmount %s"), _path.c_str())
42  << " : " << _error << endl;
43  }
44 
45  std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
46  {
47  return str << form(_("Bad file name: %s"), _filename.c_str()) << endl;
48  }
49 
50  std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
51  {
52  return str << form(
53  _("Medium not opened when trying to perform action '%s'."), _action.c_str())
54  << endl;
55  }
56 
57  std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
58  {
59  return str << form(
60  _("File '%s' not found on medium '%s'"),
61  _filename.c_str(), _url.c_str())
62  << endl;
63  }
64 
65  std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
66  {
67  return str << form(_("Cannot write file '%s'."), _filename.c_str()) << endl;
68  }
69 
70  std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
71  {
72  return str << _("Medium not attached") << ": " << _url << endl;
73  }
74 
75  std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
76  {
77  return str << _("Bad media attach point") << ": " << _url << endl;
78  }
79 
80  std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
81  {
82  return str << form(
83  // TranslatorExplanation: curl is the name of a library, don't translate
84  _("Download (curl) initialization failed for '%s'"), _url.c_str())
85  << endl;
86  }
87 
88  std::ostream & MediaMetalinkInitException::dumpOn( std::ostream & str) const
89  {
90  return str << form(
91  // TranslatorExplanation: curl is the name of a library, don't translate
92  _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
93  << endl;
94  }
95 
96  std::ostream & MediaAria2cInitException::dumpOn( std::ostream & str) const
97  {
98  return str << form(
99  // TranslatorExplanation: curl is the name of a library, don't translate
100  _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
101  << endl;
102  }
103 
104  std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
105  {
106  return str << form(
107  _("System exception '%s' on medium '%s'."),
108  _message.c_str(), _url.c_str()) << endl;
109  }
110 
111  std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
112  {
113  return str << form(
114  _("Path '%s' on medium '%s' is not a file."),
115  _path.c_str(), _url.c_str())
116  << endl;
117  }
118 
119  std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
120  {
121  return str << form(
122  _("Path '%s' on medium '%s' is not a directory."),
123  _path.c_str(), _url.c_str())
124  << endl;
125  }
126 
127  std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
128  {
129  if( _msg.empty())
130  {
131  return str << _("Malformed URI") << ": " << _url << endl;
132  }
133  else
134  {
135  return str << _msg << ": " << _url << endl;
136  }
137  }
138 
139  std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
140  {
141  return str << _("Empty host name in URI") << ": " << _url << endl;
142  }
143 
144  std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
145  {
146  return str << _("Empty filesystem in URI") << ": " << _url << endl;
147  }
148 
149  std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
150  {
151  return str << _("Empty destination in URI") << ": " << _url << endl;
152  }
153 
154  std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
155  {
156  return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str()) << endl;
157  }
158 
159  std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
160  {
161  return str << _("Operation not supported by medium") << ": " << _url << endl;
162  }
163 
164  std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
165  {
166  // TranslatorExplanation: curl is the name of a library, don't translate
167  return str << form(_(
168  "Download (curl) error for '%s':\n"
169  "Error code: %s\n"
170  "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
171  }
172 
173  std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
174  {
175  return str << form(
176  // TranslatorExplanation: curl is the name of a library, don't translate
177  _("Error occurred while setting download (curl) options for '%s':"),
178  _url.c_str())
179  << endl << _msg << endl;
180  }
181 
182  std::ostream & MediaMetalinkException::dumpOn( std::ostream & str) const
183  {
184  // TranslatorExplanation: curl is the name of a library, don't translate
185  return str << form(_(
186  "Download (metalink curl) error for '%s':\n"
187  "Error code: %s\n"
188  "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
189  }
190 
191  std::ostream & MediaMetalinkSetOptException::dumpOn( std::ostream & str) const
192  {
193  return str << form(
194  // TranslatorExplanation: curl is the name of a library, don't translate
195  _("Error occurred while setting download (metalink curl) options for '%s':"),
196  _url.c_str())
197  << endl << _msg << endl;
198  }
199 
200  std::ostream & MediaAria2cException::dumpOn( std::ostream & str) const
201  {
202  // TranslatorExplanation: curl is the name of a library, don't translate
203  return str << form(_(
204  "Download (metalink curl) error for '%s':\n"
205  "Error code: %s\n"
206  "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
207  }
208 
209  std::ostream & MediaAria2cSetOptException::dumpOn( std::ostream & str) const
210  {
211  return str << form(
212  // TranslatorExplanation: curl is the name of a library, don't translate
213  _("Error occurred while setting download (metalink curl) options for '%s':"),
214  _url.c_str())
215  << endl << _msg << endl;
216  }
217 
218  std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
219  {
220  return str << form(
221  _("Media source '%s' does not contain the desired medium"), _url.c_str())
222  << endl;
223  }
224 
225  std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
226  {
227  return str << form(_("Medium '%s' is in use by another instance"), _name.c_str())
228  << endl;
229  }
230 
231  std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
232  {
233  if( _name.empty())
234  return str << _("Cannot eject any media") << endl;
235  else
236  return str << form(_("Cannot eject media '%s'"), _name.c_str()) << endl;
237  }
238 
239  std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
240  {
241  str << msg();
242  if( !_url.asString().empty())
243  str << " (" << _url << ")";
244  if( !_err.empty())
245  str << ": " << _err;
246  return str;
247  }
248 
249  std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
250  {
251  str << form(_("Permission to access '%s' denied."), _url.c_str()) << endl;
252  if ( !_msg.empty() )
253  str << endl << _msg << endl;
254  return str;
255  }
256 
257  std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
258  {
259  str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str()) << endl;
260  if ( !_msg.empty() )
261  str << endl << _msg << endl;
262  return str;
263  }
264 
265  std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
266  {
267  str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str()) << endl;
268  if ( !_msg.empty() )
269  str << endl << _msg << endl;
270  return str;
271  }
272 
273  std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
274  {
275  str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str()) << endl;
276  if ( !_msg.empty() )
277  str << endl << _msg << endl;
278  return str;
279  }
280 
281  std::ostream & MediaNoLoopDeviceException::dumpOn( std::ostream & str ) const
282  {
283  str << form(_("Cannot find available loop device to mount the image file from '%s'"), _url.c_str()) << endl;
284  if ( !_msg.empty() )
285  str << endl << _msg << endl;
286  return str;
287  }
288 
290  } // namespace media
291 } // namespace zypp