libzypp  17.1.3
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 std::endl;
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 << ")";
34  else
35  str << ": " << _error;
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() ) << " : " << _error;
42  }
43 
44  std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
45  {
46  return str << form(_("Bad file name: %s"), _filename.c_str() );
47  }
48 
49  std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
50  {
51  return str << form(_("Medium not opened when trying to perform action '%s'."), _action.c_str() );
52  }
53 
54  std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
55  {
56  return str << form( _("File '%s' not found on medium '%s'"), _filename.c_str(), _url.c_str() );
57  }
58 
59  std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
60  {
61  return str << form(_("Cannot write file '%s'."), _filename.c_str() );
62  }
63 
64  std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
65  {
66  return str << _("Medium not attached") << ": " << _url;
67  }
68 
69  std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
70  {
71  return str << _("Bad media attach point") << ": " << _url;
72  }
73 
74  std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
75  {
76  // TranslatorExplanation: curl is the name of a library, don't translate
77  return str << form(_("Download (curl) initialization failed for '%s'"), _url.c_str() );
78  }
79 
80  std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
81  {
82  return str << form(_("System exception '%s' on medium '%s'."), _message.c_str(), _url.c_str() );
83  }
84 
85  std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
86  {
87  return str << form(_("Path '%s' on medium '%s' is not a file."), _path.c_str(), _url.c_str() );
88  }
89 
90  std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
91  {
92  return str << form(_("Path '%s' on medium '%s' is not a directory."), _path.c_str(), _url.c_str() );
93  }
94 
95  std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
96  {
97  if( _msg.empty())
98  {
99  return str << _("Malformed URI") << ": " << _url;
100  }
101  else
102  {
103  return str << _msg << ": " << _url;
104  }
105  }
106 
107  std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
108  {
109  return str << _("Empty host name in URI") << ": " << _url;
110  }
111 
112  std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
113  {
114  return str << _("Empty filesystem in URI") << ": " << _url;
115  }
116 
117  std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
118  {
119  return str << _("Empty destination in URI") << ": " << _url;
120  }
121 
122  std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
123  {
124  return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str() );
125  }
126 
127  std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
128  {
129  return str << _("Operation not supported by medium") << ": " << _url;
130  }
131 
132  std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
133  {
134  // TranslatorExplanation: curl is the name of a library, don't translate
135  return str << form(_(
136  "Download (curl) error for '%s':\n"
137  "Error code: %s\n"
138  "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
139  }
140 
141  std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
142  {
143  // TranslatorExplanation: curl is the name of a library, don't translate
144  return str << form(_("Error occurred while setting download (curl) options for '%s':"), _url.c_str() );
145  if ( !_msg.empty() )
146  str << endl << _msg;
147  }
148 
149  std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
150  {
151  return str << form(_("Media source '%s' does not contain the desired medium"), _url.c_str() );
152  }
153 
154  std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
155  {
156  return str << form(_("Medium '%s' is in use by another instance"), _name.c_str() );
157  }
158 
159  std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
160  {
161  if( _name.empty() )
162  return str << _("Cannot eject any media");
163  else
164  return str << form(_("Cannot eject media '%s'"), _name.c_str());
165  }
166 
167  std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
168  {
169  str << msg();
170  if( !_url.asString().empty())
171  str << " (" << _url << ")";
172  if( !_err.empty())
173  str << ": " << _err;
174  return str;
175  }
176 
177  std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
178  {
179  str << form(_("Permission to access '%s' denied."), _url.c_str());
180  if ( !_msg.empty() )
181  str << endl << _msg;
182  return str;
183  }
184 
185  std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
186  {
187  str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str() );
188  if ( !_msg.empty() )
189  str << endl << _msg;
190  return str;
191  }
192 
193  std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
194  {
195  str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str() );
196  if ( !_msg.empty() )
197  str << endl << _msg;
198  return str;
199  }
200 
201  std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
202  {
203  str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str() );
204  if ( !_msg.empty() )
205  str << endl << _msg;
206  return str;
207  }
208 
210  } // namespace media
211 } // namespace zypp
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Interface to gettext.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
String related utilities and Regular expression matching.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
std::string _msg
Definition: Exception.h:296
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
#define _(MSG)
Definition: Gettext.h:29
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:195