libzypp  13.10.6
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 & MediaSystemException::dumpOn( std::ostream & str) const
89  {
90  return str << form(
91  _("System exception '%s' on medium '%s'."),
92  _message.c_str(), _url.c_str()) << endl;
93  }
94 
95  std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
96  {
97  return str << form(
98  _("Path '%s' on medium '%s' is not a file."),
99  _path.c_str(), _url.c_str())
100  << endl;
101  }
102 
103  std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
104  {
105  return str << form(
106  _("Path '%s' on medium '%s' is not a directory."),
107  _path.c_str(), _url.c_str())
108  << endl;
109  }
110 
111  std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
112  {
113  if( _msg.empty())
114  {
115  return str << _("Malformed URI") << ": " << _url << endl;
116  }
117  else
118  {
119  return str << _msg << ": " << _url << endl;
120  }
121  }
122 
123  std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
124  {
125  return str << _("Empty host name in URI") << ": " << _url << endl;
126  }
127 
128  std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
129  {
130  return str << _("Empty filesystem in URI") << ": " << _url << endl;
131  }
132 
133  std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
134  {
135  return str << _("Empty destination in URI") << ": " << _url << endl;
136  }
137 
138  std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
139  {
140  return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str()) << endl;
141  }
142 
143  std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
144  {
145  return str << _("Operation not supported by medium") << ": " << _url << endl;
146  }
147 
148  std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
149  {
150  // TranslatorExplanation: curl is the name of a library, don't translate
151  return str << form(_(
152  "Download (curl) error for '%s':\n"
153  "Error code: %s\n"
154  "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
155  }
156 
157  std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
158  {
159  return str << form(
160  // TranslatorExplanation: curl is the name of a library, don't translate
161  _("Error occurred while setting download (curl) options for '%s':"),
162  _url.c_str())
163  << endl << _msg << endl;
164  }
165 
166  std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
167  {
168  return str << form(
169  _("Media source '%s' does not contain the desired medium"), _url.c_str())
170  << endl;
171  }
172 
173  std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
174  {
175  return str << form(_("Medium '%s' is in use by another instance"), _name.c_str())
176  << endl;
177  }
178 
179  std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
180  {
181  if( _name.empty())
182  return str << _("Cannot eject any media") << endl;
183  else
184  return str << form(_("Cannot eject media '%s'"), _name.c_str()) << endl;
185  }
186 
187  std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
188  {
189  str << msg();
190  if( !_url.asString().empty())
191  str << " (" << _url << ")";
192  if( !_err.empty())
193  str << ": " << _err;
194  return str;
195  }
196 
197  std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
198  {
199  str << form(_("Permission to access '%s' denied."), _url.c_str()) << endl;
200  if ( !_msg.empty() )
201  str << endl << _msg << endl;
202  return str;
203  }
204 
205  std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
206  {
207  str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str()) << endl;
208  if ( !_msg.empty() )
209  str << endl << _msg << endl;
210  return str;
211  }
212 
213  std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
214  {
215  str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str()) << endl;
216  if ( !_msg.empty() )
217  str << endl << _msg << endl;
218  return str;
219  }
220 
221  std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
222  {
223  str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str()) << endl;
224  if ( !_msg.empty() )
225  str << endl << _msg << endl;
226  return str;
227  }
228 
229  std::ostream & MediaNoLoopDeviceException::dumpOn( std::ostream & str ) const
230  {
231  str << form(_("Cannot find available loop device to mount the image file from '%s'"), _url.c_str()) << endl;
232  if ( !_msg.empty() )
233  str << endl << _msg << endl;
234  return str;
235  }
236 
238  } // namespace media
239 } // namespace zypp
Interface to gettext.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:435
#define _(MSG)
Return translated text.
Definition: Gettext.h:21
std::string form(const char *format,...)
Printf style construction of std::string.
Definition: String.cc:34