libzypp: zypp-media/mediaexception.cc Source File

libzypp 17.38.9

mediaexception.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12
13#include <iostream>
14
15#include <zypp-core/base/String.h>
16#include <zypp-core/base/Gettext.h>
17
18#include <zypp-media/MediaException>
19
20using std::endl;
21using zypp::str::form;
22
24namespace zypp
25{
26 namespace media {
28
29 MediaException::~MediaException () noexcept {}
30
31 std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
32 {
33 str << form(_("Failed to mount %s on %s"), _source.c_str(), _target.c_str() );
34 if( !_cmdout.empty())
35 str << ": " << _error << " (" << _cmdout << ")";
36 else
37 str << ": " << _error;
38 return str;
39 }
40
41 std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
42 {
43 return str << form(_("Failed to unmount %s"), _path.c_str() ) << " : " << _error;
44 }
45
46 std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
47 {
48 return str << form(_("Bad file name: %s"), _filename.c_str() );
49 }
50
51 std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
52 {
53 return str << form(_("Medium not opened when trying to perform action '%s'."), _action.c_str() );
54 }
55
56 std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
57 {
58 if ( _filename.empty () )
59 return str << form( _("File '%s' not found"), _url.c_str() );
60 else
61 return str << form( _("File '%s' not found on medium '%s'"), _filename.c_str(), _url.c_str() );
62 }
63
64 std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
65 {
66 return str << form(_("Cannot write file '%s'."), _filename.c_str() );
67 }
68
69 std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
70 {
71 return str << _("Medium not attached") << ": " << _url;
72 }
73
74 std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
75 {
76 return str << _("Bad media attach point") << ": " << _url;
77 }
78
79 std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
80 {
81 // TranslatorExplanation: curl is the name of a library, don't translate
82 return str << form(_("Download (curl) initialization failed for '%s'"), _url.c_str() );
83 }
84
85 std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
86 {
87 return str << form(_("System exception '%s' on medium '%s'."), _message.c_str(), _url.c_str() );
88 }
89
90 std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
91 {
92 return str << form(_("Path '%s' on medium '%s' is not a file."), _path.c_str(), _url.c_str() );
93 }
94
95 std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
96 {
97 return str << form(_("Path '%s' on medium '%s' is not a directory."), _path.c_str(), _url.c_str() );
98 }
99
100 std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
101 {
102 if( _msg.empty())
103 {
104 return str << _("Malformed URI") << ": " << _url;
105 }
106 else
107 {
108 return str << _msg << ": " << _url;
109 }
110 }
111
112 std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
113 {
114 return str << _("Empty host name in URI") << ": " << _url;
115 }
116
117 std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
118 {
119 return str << _("Empty filesystem in URI") << ": " << _url;
120 }
121
122 std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
123 {
124 return str << _("Empty destination in URI") << ": " << _url;
125 }
126
127 std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
128 {
129 return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str() );
130 }
131
132 std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
133 {
134 return str << _("Operation not supported by medium") << ": " << _url;
135 }
136
137 std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
138 {
139 // TranslatorExplanation: curl is the name of a library, don't translate
140 return str << form(_(
141 "Download (curl) error for '%s':\n"
142 "Error code: %s\n"
143 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
144 }
145
146 std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
147 {
148 // TranslatorExplanation: curl is the name of a library, don't translate
149 return str << form(_("Error occurred while setting download (curl) options for '%s':"), _url.c_str() );
150 if ( !_msg.empty() )
151 str << endl << _msg;
152 }
153
154 std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
155 {
156 return str << form(_("Media source '%s' does not contain the desired medium"), _url.c_str() );
157 }
158
159 std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
160 {
161 return str << form(_("Medium '%s' is in use by another instance"), _name.c_str() );
162 }
163
164 std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
165 {
166 if( _name.empty() )
167 return str << _("Cannot eject any media");
168 else
169 return str << form(_("Cannot eject media '%s'"), _name.c_str());
170 }
171
172 std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
173 {
174 str << msg();
175 if( !_url.asString().empty())
176 str << " (" << _url << ")";
177 if( !_err.empty())
178 str << ": " << _err;
179 return str;
180 }
181
182 std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
183 {
184 str << form(_("Permission to access '%s' denied."), _url.c_str());
185 if ( !_msg.empty() )
186 str << endl << _msg;
187 return str;
188 }
189
190 std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
191 {
192 str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str() );
193 if ( !_msg.empty() )
194 str << endl << _msg;
195 return str;
196 }
197
198 std::ostream &MediaFileSizeExceededException::dumpOn(std::ostream &str) const
199 {
200 str << form(_("Downloaded data exceeded the expected filesize '%s' of '%s'."), _expectedFileSize.asString().c_str(), _url.c_str() );
201 if ( !_msg.empty() )
202 str << endl << _msg;
203 return str;
204 }
205
206 std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
207 {
208 str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str() );
209 if ( !_msg.empty() )
210 str << endl << _msg;
211 return str;
212 }
213
214 std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
215 {
216 str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str() );
217 if ( !_msg.empty() )
218 str << endl << _msg;
219 return str;
220 }
221
222 std::ostream & MediaJammedException::dumpOn( std::ostream & str ) const {
223 str << _("No free ressources available to attach medium.");
224 return str;
225 }
226
228 } // namespace media
229} // namespace zypp
Gettext.h
_
#define _(MSG)
Definition Gettext.h:39
String.h
zypp::Exception::msg
const std::string & msg() const
Return the message string provided to the ctor.
Definition Exception.h:206
zypp::media::MediaBadAttachPointException::_url
std::string _url
Definition mediaexception.h:223
zypp::media::MediaBadAttachPointException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:74
zypp::media::MediaBadCAException::_url
std::string _url
Definition mediaexception.h:554
zypp::media::MediaBadCAException::_msg
std::string _msg
Definition mediaexception.h:555
zypp::media::MediaBadCAException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:214
zypp::media::MediaBadFilenameException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:46
zypp::media::MediaBadFilenameException::_filename
std::string _filename
Definition mediaexception.h:146
zypp::media::MediaBadUrlEmptyDestinationException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:122
zypp::media::MediaBadUrlEmptyFilesystemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:117
zypp::media::MediaBadUrlEmptyHostException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:112
zypp::media::MediaBadUrlException::_url
std::string _url
Definition mediaexception.h:303
zypp::media::MediaBadUrlException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:100
zypp::media::MediaBadUrlException::_msg
std::string _msg
Definition mediaexception.h:304
zypp::media::MediaCurlException::_url
std::string _url
Definition mediaexception.h:379
zypp::media::MediaCurlException::_err
std::string _err
Definition mediaexception.h:380
zypp::media::MediaCurlException::_msg
std::string _msg
Definition mediaexception.h:381
zypp::media::MediaCurlException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:137
zypp::media::MediaCurlInitException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:79
zypp::media::MediaCurlInitException::_url
std::string _url
Definition mediaexception.h:237
zypp::media::MediaCurlSetOptException::_msg
std::string _msg
Definition mediaexception.h:396
zypp::media::MediaCurlSetOptException::_url
std::string _url
Definition mediaexception.h:395
zypp::media::MediaCurlSetOptException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:146
zypp::media::MediaException::~MediaException
~MediaException() noexcept override
Dtor.
Definition mediaexception.cc:29
zypp::media::MediaFileNotFoundException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:56
zypp::media::MediaFileNotFoundException::_filename
std::string _filename
Definition mediaexception.h:181
zypp::media::MediaFileNotFoundException::_url
std::string _url
Definition mediaexception.h:180
zypp::media::MediaFileSizeExceededException::_url
std::string _url
Definition mediaexception.h:524
zypp::media::MediaFileSizeExceededException::_msg
std::string _msg
Definition mediaexception.h:525
zypp::media::MediaFileSizeExceededException::_expectedFileSize
ByteCount _expectedFileSize
Definition mediaexception.h:526
zypp::media::MediaFileSizeExceededException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:198
zypp::media::MediaForbiddenException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:182
zypp::media::MediaForbiddenException::_msg
std::string _msg
Definition mediaexception.h:495
zypp::media::MediaForbiddenException::_url
std::string _url
Definition mediaexception.h:494
zypp::media::MediaIsSharedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:159
zypp::media::MediaIsSharedException::_name
std::string _name
Definition mediaexception.h:427
zypp::media::MediaJammedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:222
zypp::media::MediaMountException::_source
std::string _source
Definition mediaexception.h:91
zypp::media::MediaMountException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:31
zypp::media::MediaMountException::_cmdout
std::string _cmdout
Definition mediaexception.h:93
zypp::media::MediaMountException::_error
std::string _error
Definition mediaexception.h:90
zypp::media::MediaMountException::_target
std::string _target
Definition mediaexception.h:92
zypp::media::MediaNotADirException::_path
std::string _path
Definition mediaexception.h:288
zypp::media::MediaNotADirException::_url
std::string _url
Definition mediaexception.h:287
zypp::media::MediaNotADirException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:95
zypp::media::MediaNotAFileException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:90
zypp::media::MediaNotAFileException::_path
std::string _path
Definition mediaexception.h:271
zypp::media::MediaNotAFileException::_url
std::string _url
Definition mediaexception.h:270
zypp::media::MediaNotAttachedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:69
zypp::media::MediaNotAttachedException::_url
std::string _url
Definition mediaexception.h:209
zypp::media::MediaNotDesiredException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:154
zypp::media::MediaNotDesiredException::_url
std::string _url
Definition mediaexception.h:410
zypp::media::MediaNotEjectedException::_name
std::string _name
Definition mediaexception.h:446
zypp::media::MediaNotEjectedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:164
zypp::media::MediaNotOpenException::_action
std::string _action
Definition mediaexception.h:160
zypp::media::MediaNotOpenException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:51
zypp::media::MediaNotSupportedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:132
zypp::media::MediaNotSupportedException::_url
std::string _url
Definition mediaexception.h:361
zypp::media::MediaSystemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:85
zypp::media::MediaSystemException::_url
std::string _url
Definition mediaexception.h:253
zypp::media::MediaSystemException::_message
std::string _message
Definition mediaexception.h:254
zypp::media::MediaTemporaryProblemException::_url
std::string _url
Definition mediaexception.h:540
zypp::media::MediaTemporaryProblemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:206
zypp::media::MediaTemporaryProblemException::_msg
std::string _msg
Definition mediaexception.h:541
zypp::media::MediaTimeoutException::_url
std::string _url
Definition mediaexception.h:508
zypp::media::MediaTimeoutException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:190
zypp::media::MediaTimeoutException::_msg
std::string _msg
Definition mediaexception.h:509
zypp::media::MediaUnauthorizedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:172
zypp::media::MediaUnauthorizedException::_err
std::string _err
Definition mediaexception.h:480
zypp::media::MediaUnauthorizedException::_url
Url _url
Definition mediaexception.h:479
zypp::media::MediaUnmountException::_path
std::string _path
Definition mediaexception.h:114
zypp::media::MediaUnmountException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:41
zypp::media::MediaUnmountException::_error
std::string _error
Definition mediaexception.h:113
zypp::media::MediaUnsupportedUrlSchemeException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:127
zypp::media::MediaWriteException::_filename
std::string _filename
Definition mediaexception.h:195
zypp::media::MediaWriteException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:64
form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
str
String related utilities and Regular expression matching.
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2