libzypp 17.36.7

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
20 using std::endl;
21 using zypp::str::form;
22
24 namespace 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 return str << form( _("File '%s' not found on medium '%s'"), _filename.c_str(), _url.c_str() );
59 }
60
61 std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
62 {
63 return str << form(_("Cannot write file '%s'."), _filename.c_str() );
64 }
65
66 std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
67 {
68 return str << _("Medium not attached") << ": " << _url;
69 }
70
71 std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str) const
72 {
73 return str << _("Bad media attach point") << ": " << _url;
74 }
75
76 std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
77 {
78 // TranslatorExplanation: curl is the name of a library, don't translate
79 return str << form(_("Download (curl) initialization failed for '%s'"), _url.c_str() );
80 }
81
82 std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
83 {
84 return str << form(_("System exception '%s' on medium '%s'."), _message.c_str(), _url.c_str() );
85 }
86
87 std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
88 {
89 return str << form(_("Path '%s' on medium '%s' is not a file."), _path.c_str(), _url.c_str() );
90 }
91
92 std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
93 {
94 return str << form(_("Path '%s' on medium '%s' is not a directory."), _path.c_str(), _url.c_str() );
95 }
96
97 std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
98 {
99 if( _msg.empty())
100 {
101 return str << _("Malformed URI") << ": " << _url;
102 }
103 else
104 {
105 return str << _msg << ": " << _url;
106 }
107 }
108
109 std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str) const
110 {
111 return str << _("Empty host name in URI") << ": " << _url;
112 }
113
114 std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream & str) const
115 {
116 return str << _("Empty filesystem in URI") << ": " << _url;
117 }
118
119 std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream & str) const
120 {
121 return str << _("Empty destination in URI") << ": " << _url;
122 }
123
124 std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream & str) const
125 {
126 return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str() );
127 }
128
129 std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str) const
130 {
131 return str << _("Operation not supported by medium") << ": " << _url;
132 }
133
134 std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
135 {
136 // TranslatorExplanation: curl is the name of a library, don't translate
137 return str << form(_(
138 "Download (curl) error for '%s':\n"
139 "Error code: %s\n"
140 "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
141 }
142
143 std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
144 {
145 // TranslatorExplanation: curl is the name of a library, don't translate
146 return str << form(_("Error occurred while setting download (curl) options for '%s':"), _url.c_str() );
147 if ( !_msg.empty() )
148 str << endl << _msg;
149 }
150
151 std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
152 {
153 return str << form(_("Media source '%s' does not contain the desired medium"), _url.c_str() );
154 }
155
156 std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
157 {
158 return str << form(_("Medium '%s' is in use by another instance"), _name.c_str() );
159 }
160
161 std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
162 {
163 if( _name.empty() )
164 return str << _("Cannot eject any media");
165 else
166 return str << form(_("Cannot eject media '%s'"), _name.c_str());
167 }
168
169 std::ostream & MediaUnauthorizedException::dumpOn( std::ostream & str ) const
170 {
171 str << msg();
172 if( !_url.asString().empty())
173 str << " (" << _url << ")";
174 if( !_err.empty())
175 str << ": " << _err;
176 return str;
177 }
178
179 std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
180 {
181 str << form(_("Permission to access '%s' denied."), _url.c_str());
182 if ( !_msg.empty() )
183 str << endl << _msg;
184 return str;
185 }
186
187 std::ostream & MediaTimeoutException::dumpOn( std::ostream & str ) const
188 {
189 str << form(_("Timeout exceeded when accessing '%s'."), _url.c_str() );
190 if ( !_msg.empty() )
191 str << endl << _msg;
192 return str;
193 }
194
195 std::ostream &MediaFileSizeExceededException::dumpOn(std::ostream &str) const
196 {
197 str << form(_("Downloaded data exceeded the expected filesize '%s' of '%s'."), _expectedFileSize.asString().c_str(), _url.c_str() );
198 if ( !_msg.empty() )
199 str << endl << _msg;
200 return str;
201 }
202
203 std::ostream & MediaTemporaryProblemException::dumpOn( std::ostream & str ) const
204 {
205 str << form(_("Location '%s' is temporarily unaccessible."), _url.c_str() );
206 if ( !_msg.empty() )
207 str << endl << _msg;
208 return str;
209 }
210
211 std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
212 {
213 str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str() );
214 if ( !_msg.empty() )
215 str << endl << _msg;
216 return str;
217 }
218
219 std::ostream & MediaJammedException::dumpOn( std::ostream & str ) const {
220 str << _("No free ressources available to attach medium.");
221 return str;
222 }
223
225 } // namespace media
226} // namespace zypp
zypp::Exception::msg
const std::string & msg() const
Return the message string provided to the ctor.
Definition Exception.h:196
zypp::media::MediaBadAttachPointException::_url
std::string _url
Definition mediaexception.h:219
zypp::media::MediaBadAttachPointException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:71
zypp::media::MediaBadCAException::_url
std::string _url
Definition mediaexception.h:550
zypp::media::MediaBadCAException::_msg
std::string _msg
Definition mediaexception.h:551
zypp::media::MediaBadCAException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:211
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:119
zypp::media::MediaBadUrlEmptyFilesystemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:114
zypp::media::MediaBadUrlEmptyHostException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:109
zypp::media::MediaBadUrlException::_url
std::string _url
Definition mediaexception.h:299
zypp::media::MediaBadUrlException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:97
zypp::media::MediaBadUrlException::_msg
std::string _msg
Definition mediaexception.h:300
zypp::media::MediaCurlException::_url
std::string _url
Definition mediaexception.h:375
zypp::media::MediaCurlException::_err
std::string _err
Definition mediaexception.h:376
zypp::media::MediaCurlException::_msg
std::string _msg
Definition mediaexception.h:377
zypp::media::MediaCurlException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:134
zypp::media::MediaCurlInitException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:76
zypp::media::MediaCurlInitException::_url
std::string _url
Definition mediaexception.h:233
zypp::media::MediaCurlSetOptException::_msg
std::string _msg
Definition mediaexception.h:392
zypp::media::MediaCurlSetOptException::_url
std::string _url
Definition mediaexception.h:391
zypp::media::MediaCurlSetOptException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:143
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:177
zypp::media::MediaFileNotFoundException::_url
std::string _url
Definition mediaexception.h:176
zypp::media::MediaFileSizeExceededException::_url
std::string _url
Definition mediaexception.h:520
zypp::media::MediaFileSizeExceededException::_msg
std::string _msg
Definition mediaexception.h:521
zypp::media::MediaFileSizeExceededException::_expectedFileSize
ByteCount _expectedFileSize
Definition mediaexception.h:522
zypp::media::MediaFileSizeExceededException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:195
zypp::media::MediaForbiddenException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:179
zypp::media::MediaForbiddenException::_msg
std::string _msg
Definition mediaexception.h:491
zypp::media::MediaForbiddenException::_url
std::string _url
Definition mediaexception.h:490
zypp::media::MediaIsSharedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:156
zypp::media::MediaIsSharedException::_name
std::string _name
Definition mediaexception.h:423
zypp::media::MediaJammedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:219
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:284
zypp::media::MediaNotADirException::_url
std::string _url
Definition mediaexception.h:283
zypp::media::MediaNotADirException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:92
zypp::media::MediaNotAFileException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:87
zypp::media::MediaNotAFileException::_path
std::string _path
Definition mediaexception.h:267
zypp::media::MediaNotAFileException::_url
std::string _url
Definition mediaexception.h:266
zypp::media::MediaNotAttachedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:66
zypp::media::MediaNotAttachedException::_url
std::string _url
Definition mediaexception.h:205
zypp::media::MediaNotDesiredException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:151
zypp::media::MediaNotDesiredException::_url
std::string _url
Definition mediaexception.h:406
zypp::media::MediaNotEjectedException::_name
std::string _name
Definition mediaexception.h:442
zypp::media::MediaNotEjectedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:161
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:129
zypp::media::MediaNotSupportedException::_url
std::string _url
Definition mediaexception.h:357
zypp::media::MediaSystemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:82
zypp::media::MediaSystemException::_url
std::string _url
Definition mediaexception.h:249
zypp::media::MediaSystemException::_message
std::string _message
Definition mediaexception.h:250
zypp::media::MediaTemporaryProblemException::_url
std::string _url
Definition mediaexception.h:536
zypp::media::MediaTemporaryProblemException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:203
zypp::media::MediaTemporaryProblemException::_msg
std::string _msg
Definition mediaexception.h:537
zypp::media::MediaTimeoutException::_url
std::string _url
Definition mediaexception.h:504
zypp::media::MediaTimeoutException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:187
zypp::media::MediaTimeoutException::_msg
std::string _msg
Definition mediaexception.h:505
zypp::media::MediaUnauthorizedException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:169
zypp::media::MediaUnauthorizedException::_err
std::string _err
Definition mediaexception.h:476
zypp::media::MediaUnauthorizedException::_url
Url _url
Definition mediaexception.h:475
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:124
zypp::media::MediaWriteException::_filename
std::string _filename
Definition mediaexception.h:191
zypp::media::MediaWriteException::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload this to print a proper error message.
Definition mediaexception.cc:61
form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
str
String related utilities and Regular expression matching.
zypp::media
Definition MediaCD.cc:47
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
Gettext.h
_
#define _(MSG)
Definition Gettext.h:39
String.h