libzypp 17.28.8
MediaException.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
13#define ZYPP_MEDIA_MEDIAEXCEPTION_H
14
15#include <iosfwd>
16
17#include <string>
18#include <vector>
19
20#include <zypp/base/Exception.h>
21#include <zypp/Pathname.h>
22#include <zypp/Url.h>
23#include <zypp/ByteCount.h>
24
26namespace zypp
27{
28 namespace media {
30 //
31 // CLASS NAME : MediaException
36 {
37 public:
41 MediaException() : Exception( "Media Exception" )
42 {}
46 MediaException( const std::string & msg_r )
47 : Exception( msg_r )
48 {}
49
51 virtual ~MediaException() noexcept override;
52 };
53
55 {
56 public:
58 : MediaException( "Media Mount Exception" )
59 {}
60
64 MediaMountException( const std::string & error_r,
65 const std::string & source_r,
66 const std::string & target_r,
67 const std::string & cmdout_r="")
69 , _error(error_r)
70 , _source(source_r)
71 , _target(target_r)
72 , _cmdout(cmdout_r)
73 {}
75 virtual ~MediaMountException() noexcept {}
76
77 const std::string & mountError() const
78 { return _error; }
79 const std::string & mountSource() const
80 { return _source; }
81 const std::string & mountTarget() const
82 { return _target; }
83 const std::string & mountOutput() const
84 { return _cmdout; }
85
86 protected:
87 virtual std::ostream & dumpOn( std::ostream & str ) const;
88 private:
89 std::string _error;
90 std::string _source;
91 std::string _target;
92 std::string _cmdout;
93 };
94
96 {
97 public:
101 MediaUnmountException( const std::string & error_r,
102 const std::string & path_r )
104 , _error(error_r)
105 , _path(path_r)
106 {}
108 virtual ~MediaUnmountException() noexcept {}
109 protected:
110 virtual std::ostream & dumpOn( std::ostream & str ) const;
111 private:
112 std::string _error;
113 std::string _path;
114 };
115
117 {
118 public:
119 MediaBadFilenameException(const std::string & filename_r)
121 , _filename(filename_r)
122 {}
123 virtual ~MediaBadFilenameException() noexcept {}
124 std::string filename() const { return _filename; }
125 protected:
126 virtual std::ostream & dumpOn( std::ostream & str ) const;
127 private:
128 std::string _filename;
129 };
130
132 {
133 public:
134 MediaNotOpenException(const std::string & action_r)
136 , _action(action_r)
137 {}
138 virtual ~MediaNotOpenException() noexcept {}
139 protected:
140 virtual std::ostream & dumpOn( std::ostream & str ) const;
141 private:
142 std::string _action;
143 };
144
146 {
147 public:
149 const Pathname & filename_r)
151 , _url(url_r.asString())
152 , _filename(filename_r.asString())
153 {}
154 virtual ~MediaFileNotFoundException() noexcept {}
155 protected:
156 virtual std::ostream & dumpOn( std::ostream & str ) const;
157 private:
158 std::string _url;
159 std::string _filename;
160 };
161
163 {
164 public:
165 MediaWriteException(const Pathname & filename_r)
167 , _filename(filename_r.asString())
168 {}
169 virtual ~MediaWriteException() noexcept {}
170 protected:
171 virtual std::ostream & dumpOn( std::ostream & str ) const;
172 private:
173 std::string _filename;
174 };
175
177 {
178 public:
181 , _url(url_r.asString())
182 {}
183 virtual ~MediaNotAttachedException() noexcept {}
184 protected:
185 virtual std::ostream & dumpOn( std::ostream & str ) const;
186 private:
187 std::string _url;
188 };
189
191 {
192 public:
195 , _url(url_r.asString())
196 {}
197 virtual ~MediaBadAttachPointException() noexcept {}
198 protected:
199 virtual std::ostream & dumpOn( std::ostream & str ) const;
200 private:
201 std::string _url;
202 };
203
205 {
206 public:
209 , _url(url_r.asString())
210 {}
211 virtual ~MediaCurlInitException() noexcept {}
212 protected:
213 virtual std::ostream & dumpOn( std::ostream & str ) const;
214 private:
215 std::string _url;
216 };
217
219 {
220 public:
222 const std::string & message_r)
224 , _url(url_r.asString())
225 , _message(message_r)
226 {}
227 virtual ~MediaSystemException() noexcept {}
228 protected:
229 virtual std::ostream & dumpOn( std::ostream & str ) const;
230 private:
231 std::string _url;
232 std::string _message;
233 };
234
236 {
237 public:
239 const Pathname & path_r)
241 , _url(url_r.asString())
242 , _path(path_r.asString())
243 {}
244 virtual ~MediaNotAFileException() noexcept {}
245 protected:
246 virtual std::ostream & dumpOn( std::ostream & str ) const;
247 private:
248 std::string _url;
249 std::string _path;
250 };
251
253 {
254 public:
256 const Pathname & path_r)
258 , _url(url_r.asString())
259 , _path(path_r.asString())
260 {}
261 virtual ~MediaNotADirException() noexcept {}
262 protected:
263 virtual std::ostream & dumpOn( std::ostream & str ) const;
264 private:
265 std::string _url;
266 std::string _path;
267 };
268
270 {
271 public:
273 const std::string &msg_r = std::string())
275 , _url(url_r.asString())
276 , _msg(msg_r)
277 {}
278 virtual ~MediaBadUrlException() noexcept {}
279 protected:
280 virtual std::ostream & dumpOn( std::ostream & str ) const;
281 std::string _url;
282 std::string _msg;
283 };
284
286 {
287 public:
289 : MediaBadUrlException(url_r)
290 {}
291 virtual ~MediaBadUrlEmptyHostException() noexcept {}
292 protected:
293 virtual std::ostream & dumpOn( std::ostream & str ) const;
294 };
295
297 {
298 public:
300 : MediaBadUrlException(url_r)
301 {}
303 protected:
304 virtual std::ostream & dumpOn( std::ostream & str ) const;
305 };
306
308 {
309 public:
311 : MediaBadUrlException(url_r)
312 {}
314 protected:
315 virtual std::ostream & dumpOn( std::ostream & str ) const;
316 };
317
319 {
320 public:
322 : MediaBadUrlException(url_r)
323 {}
325 protected:
326 virtual std::ostream & dumpOn( std::ostream & str ) const;
327 };
328
330 {
331 public:
334 , _url(url_r.asString())
335 {}
336 virtual ~MediaNotSupportedException() noexcept {}
337 protected:
338 virtual std::ostream & dumpOn( std::ostream & str ) const;
339 std::string _url;
340 };
341
343 {
344 public:
345 MediaCurlException(const Url & url_r,
346 const std::string & err_r,
347 const std::string & msg_r)
349 , _url(url_r.asString())
350 , _err(err_r)
351 , _msg(msg_r)
352 {}
353 virtual ~MediaCurlException() noexcept {}
354 std::string errstr() const { return _err; }
355 protected:
356 virtual std::ostream & dumpOn( std::ostream & str ) const;
357 std::string _url;
358 std::string _err;
359 std::string _msg;
360 };
361
363 {
364 public:
365 MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
367 , _url(url_r.asString())
368 , _msg(msg_r)
369 {}
370 virtual ~MediaCurlSetOptException() noexcept {}
371 protected:
372 virtual std::ostream & dumpOn( std::ostream & str ) const;
373 std::string _url;
374 std::string _msg;
375 };
376
378 {
379 public:
382 , _url(url_r.asString())
383 {}
384 virtual ~MediaNotDesiredException() noexcept {}
385 protected:
386 virtual std::ostream & dumpOn( std::ostream & str ) const;
387 private:
388 std::string _url;
389 };
390
392 {
393 public:
397 MediaIsSharedException(const std::string &name)
399 , _name(name)
400 {}
401 virtual ~MediaIsSharedException() noexcept {}
402 protected:
403 virtual std::ostream & dumpOn( std::ostream & str ) const;
404 private:
405 std::string _name;
406 };
407
409 {
410 public:
412 : MediaException("Can't eject any media")
413 , _name("")
414 {}
415
416 MediaNotEjectedException(const std::string &name)
417 : MediaException("Can't eject media")
418 , _name(name)
419 {}
420 virtual ~MediaNotEjectedException() noexcept {}
421 protected:
422 virtual std::ostream & dumpOn( std::ostream & str ) const;
423 private:
424 std::string _name;
425 };
426
428 {
429 public:
431 : MediaException("Unauthorized media access")
432 , _url("")
433 , _err("")
434 , _hint("")
435 {}
436
438 const std::string &msg_r,
439 const std::string &err_r,
440 const std::string &hint_r)
441 : MediaException(msg_r)
442 , _url(url_r)
443 , _err(err_r)
444 , _hint(hint_r)
445 {}
446
447 virtual ~MediaUnauthorizedException() noexcept {}
448
449 const Url & url() const { return _url; }
450 const std::string & err() const { return _err; }
452 const std::string & hint() const { return _hint; }
453
454 protected:
455 virtual std::ostream & dumpOn( std::ostream & str ) const;
456 private:
458 std::string _err;
459 std::string _hint;
460 };
461
463 {
464 public:
465 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
467 , _url(url_r.asString()), _msg(msg)
468 {}
469 virtual ~MediaForbiddenException() noexcept {}
470 protected:
471 virtual std::ostream & dumpOn( std::ostream & str ) const;
472 std::string _url;
473 std::string _msg;
474 };
475
477 {
478 public:
479 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
481 , _url(url_r.asString()), _msg(msg)
482 {}
483 virtual ~MediaTimeoutException() noexcept {}
484 protected:
485 virtual std::ostream & dumpOn( std::ostream & str ) const;
486 std::string _url;
487 std::string _msg;
488 };
489
491 {
492 public:
493 MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
495 , _url(url_r.asString())
496 , _msg(msg)
497 , _expectedFileSize(cnt_r)
498 {}
500 protected:
501 virtual std::ostream & dumpOn( std::ostream & str ) const;
502 std::string _url;
503 std::string _msg;
505 };
506
509 {
510 public:
511 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
513 , _url(url_r.asString()), _msg(msg)
514 {}
516 protected:
517 virtual std::ostream & dumpOn( std::ostream & str ) const;
518 std::string _url;
519 std::string _msg;
520 };
521
523 {
524 public:
525 MediaBadCAException(const Url & url_r, const std::string & msg = "")
527 , _url(url_r.asString()), _msg(msg)
528 {}
529 virtual ~MediaBadCAException() noexcept {}
530 protected:
531 virtual std::ostream & dumpOn( std::ostream & str ) const;
532 std::string _url;
533 std::string _msg;
534 };
535
537 {
538 public:
539 MediaInvalidCredentialsException( const std::string & msg = "" )
541 {}
543 };
544
546 } // namespace media
547} // namespace zypp
549#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
gpgme_error_t _err
Definition: KeyManager.cc:64
Store and operate with byte count.
Definition: ByteCount.h:31
Base class for Exception.
Definition: Exception.h:146
std::string _msg
Definition: Exception.h:296
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: Exception.cc:141
std::string asString() const
Error message provided by dumpOn as string.
Definition: Exception.cc:75
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:195
Url manipulation class.
Definition: Url.h:92
MediaBadCAException(const Url &url_r, const std::string &msg="")
virtual ~MediaBadCAException() noexcept
MediaBadFilenameException(const std::string &filename_r)
virtual ~MediaBadUrlException() noexcept
MediaBadUrlException(const Url &url_r, const std::string &msg_r=std::string())
virtual ~MediaCurlException() noexcept
MediaCurlException(const Url &url_r, const std::string &err_r, const std::string &msg_r)
virtual ~MediaCurlInitException() noexcept
MediaCurlSetOptException(const Url &url_r, const std::string &msg_r)
virtual ~MediaCurlSetOptException() noexcept
Just inherits Exception to separate media exceptions.
MediaException(const std::string &msg_r)
Ctor taking message.
virtual ~MediaException() noexcept override
Dtor.
MediaException()
Ctor taking message.
MediaFileNotFoundException(const Url &url_r, const Pathname &filename_r)
MediaFileSizeExceededException(const Url &url_r, const ByteCount &cnt_r, const std::string &msg="")
virtual ~MediaForbiddenException() noexcept
MediaForbiddenException(const Url &url_r, const std::string &msg="")
MediaInvalidCredentialsException(const std::string &msg="")
virtual ~MediaIsSharedException() noexcept
MediaIsSharedException(const std::string &name)
const std::string & mountError() const
const std::string & mountSource() const
const std::string & mountTarget() const
MediaMountException(const std::string &error_r, const std::string &source_r, const std::string &target_r, const std::string &cmdout_r="")
Ctor taking message.
virtual ~MediaMountException() noexcept
Dtor.
const std::string & mountOutput() const
MediaNotADirException(const Url &url_r, const Pathname &path_r)
virtual ~MediaNotADirException() noexcept
virtual ~MediaNotAFileException() noexcept
MediaNotAFileException(const Url &url_r, const Pathname &path_r)
virtual ~MediaNotDesiredException() noexcept
MediaNotEjectedException(const std::string &name)
virtual ~MediaNotEjectedException() noexcept
MediaNotOpenException(const std::string &action_r)
virtual ~MediaNotOpenException() noexcept
MediaSystemException(const Url &url_r, const std::string &message_r)
virtual ~MediaSystemException() noexcept
MediaTemporaryProblemException(const Url &url_r, const std::string &msg="")
virtual ~MediaTimeoutException() noexcept
MediaTimeoutException(const Url &url_r, const std::string &msg="")
const std::string & err() const
MediaUnauthorizedException(const Url &url_r, const std::string &msg_r, const std::string &err_r, const std::string &hint_r)
const std::string & hint() const
comma separated list of available authentication types
MediaUnmountException(const std::string &error_r, const std::string &path_r)
Ctor taking message.
virtual ~MediaUnmountException() noexcept
Dtor.
virtual ~MediaWriteException() noexcept
MediaWriteException(const Pathname &filename_r)
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2