libzypp 17.35.19
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 <utility>
19#include <vector>
20
22#include <zypp-core/Pathname.h>
23#include <zypp-core/Url.h>
24#include <zypp-core/ByteCount.h>
25
27namespace zypp
28{
29 namespace media {
31 //
32 // CLASS NAME : MediaException
37 {
38 public:
42 MediaException() : Exception( "Media Exception" )
43 {}
44
47 MediaException( const std::string & msg_r )
48 : Exception( msg_r )
49 {}
50
52 ~MediaException() noexcept override;
53 };
54
56 {
57 public:
59 : MediaException( "Media Mount Exception" )
60 {}
61
65 MediaMountException( std::string error_r,
66 std::string source_r,
67 std::string target_r,
68 std::string cmdout_r="")
70 , _error(std::move(error_r))
71 , _source(std::move(source_r))
72 , _target(std::move(target_r))
73 , _cmdout(std::move(cmdout_r))
74 {}
75
76 ~MediaMountException() noexcept override {}
77
78 const std::string & mountError() const
79 { return _error; }
80 const std::string & mountSource() const
81 { return _source; }
82 const std::string & mountTarget() const
83 { return _target; }
84 const std::string & mountOutput() const
85 { return _cmdout; }
86
87 protected:
88 std::ostream & dumpOn( std::ostream & str ) const override;
89 private:
90 std::string _error;
91 std::string _source;
92 std::string _target;
93 std::string _cmdout;
94 };
95
97 {
98 public:
102 MediaUnmountException( std::string error_r,
103 std::string path_r )
105 , _error(std::move(error_r))
106 , _path(std::move(path_r))
107 {}
108
109 ~MediaUnmountException() noexcept override {}
110 protected:
111 std::ostream & dumpOn( std::ostream & str ) const override;
112 private:
113 std::string _error;
114 std::string _path;
115 };
116
118 {
119 public:
123 MediaJammedException() : MediaException( "Media Jammed Exception" )
124 {}
125
127 ~MediaJammedException() noexcept override {};
128 protected:
129 std::ostream & dumpOn( std::ostream & str ) const override;
130
131 private:
132 };
133
135 {
136 public:
137 MediaBadFilenameException(std::string filename_r)
139 , _filename(std::move(filename_r))
140 {}
141 ~MediaBadFilenameException() noexcept override {}
142 std::string filename() const { return _filename; }
143 protected:
144 std::ostream & dumpOn( std::ostream & str ) const override;
145 private:
146 std::string _filename;
147 };
148
150 {
151 public:
152 MediaNotOpenException(std::string action_r)
154 , _action(std::move(action_r))
155 {}
156 ~MediaNotOpenException() noexcept override {}
157 protected:
158 std::ostream & dumpOn( std::ostream & str ) const override;
159 private:
160 std::string _action;
161 };
162
164 {
165 public:
167 const Pathname & filename_r)
169 , _url(url_r.asString())
170 , _filename(filename_r.asString())
171 {}
172 ~MediaFileNotFoundException() noexcept override {}
173 protected:
174 std::ostream & dumpOn( std::ostream & str ) const override;
175 private:
176 std::string _url;
177 std::string _filename;
178 };
179
181 {
182 public:
183 MediaWriteException(const Pathname & filename_r)
185 , _filename(filename_r.asString())
186 {}
187 ~MediaWriteException() noexcept override {}
188 protected:
189 std::ostream & dumpOn( std::ostream & str ) const override;
190 private:
191 std::string _filename;
192 };
193
195 {
196 public:
199 , _url(url_r.asString())
200 {}
201 ~MediaNotAttachedException() noexcept override {}
202 protected:
203 std::ostream & dumpOn( std::ostream & str ) const override;
204 private:
205 std::string _url;
206 };
207
209 {
210 public:
213 , _url(url_r.asString())
214 {}
215 ~MediaBadAttachPointException() noexcept override {}
216 protected:
217 std::ostream & dumpOn( std::ostream & str ) const override;
218 private:
219 std::string _url;
220 };
221
223 {
224 public:
227 , _url(url_r.asString())
228 {}
229 ~MediaCurlInitException() noexcept override {}
230 protected:
231 std::ostream & dumpOn( std::ostream & str ) const override;
232 private:
233 std::string _url;
234 };
235
237 {
238 public:
240 std::string message_r)
242 , _url(url_r.asString())
243 , _message(std::move(message_r))
244 {}
245 ~MediaSystemException() noexcept override {}
246 protected:
247 std::ostream & dumpOn( std::ostream & str ) const override;
248 private:
249 std::string _url;
250 std::string _message;
251 };
252
254 {
255 public:
257 const Pathname & path_r)
259 , _url(url_r.asString())
260 , _path(path_r.asString())
261 {}
262 ~MediaNotAFileException() noexcept override {}
263 protected:
264 std::ostream & dumpOn( std::ostream & str ) const override;
265 private:
266 std::string _url;
267 std::string _path;
268 };
269
271 {
272 public:
274 const Pathname & path_r)
276 , _url(url_r.asString())
277 , _path(path_r.asString())
278 {}
279 ~MediaNotADirException() noexcept override {}
280 protected:
281 std::ostream & dumpOn( std::ostream & str ) const override;
282 private:
283 std::string _url;
284 std::string _path;
285 };
286
288 {
289 public:
291 std::string msg_r = std::string())
293 , _url(url_r.asString())
294 , _msg(std::move(msg_r))
295 {}
296 ~MediaBadUrlException() noexcept override {}
297 protected:
298 std::ostream & dumpOn( std::ostream & str ) const override;
299 std::string _url;
300 std::string _msg;
301 };
302
304 {
305 public:
307 : MediaBadUrlException(url_r)
308 {}
309 ~MediaBadUrlEmptyHostException() noexcept override {}
310 protected:
311 std::ostream & dumpOn( std::ostream & str ) const override;
312 };
313
315 {
316 public:
321 protected:
322 std::ostream & dumpOn( std::ostream & str ) const override;
323 };
324
326 {
327 public:
332 protected:
333 std::ostream & dumpOn( std::ostream & str ) const override;
334 };
335
337 {
338 public:
343 protected:
344 std::ostream & dumpOn( std::ostream & str ) const override;
345 };
346
348 {
349 public:
352 , _url(url_r.asString())
353 {}
354 ~MediaNotSupportedException() noexcept override {}
355 protected:
356 std::ostream & dumpOn( std::ostream & str ) const override;
357 std::string _url;
358 };
359
361 {
362 public:
363 MediaCurlException(const Url & url_r,
364 std::string err_r,
365 std::string msg_r)
367 , _url(url_r.asString())
368 , _err(std::move(err_r))
369 , _msg(std::move(msg_r))
370 {}
371 ~MediaCurlException() noexcept override {}
372 std::string errstr() const { return _err; }
373 protected:
374 std::ostream & dumpOn( std::ostream & str ) const override;
375 std::string _url;
376 std::string _err;
377 std::string _msg;
378 };
379
381 {
382 public:
383 MediaCurlSetOptException(const Url & url_r, std::string msg_r)
385 , _url(url_r.asString())
386 , _msg(std::move(msg_r))
387 {}
388 ~MediaCurlSetOptException() noexcept override {}
389 protected:
390 std::ostream & dumpOn( std::ostream & str ) const override;
391 std::string _url;
392 std::string _msg;
393 };
394
396 {
397 public:
400 , _url(url_r.asString())
401 {}
402 ~MediaNotDesiredException() noexcept override {}
403 protected:
404 std::ostream & dumpOn( std::ostream & str ) const override;
405 private:
406 std::string _url;
407 };
408
410 {
411 public:
415 MediaIsSharedException(std::string name)
417 , _name(std::move(name))
418 {}
419 ~MediaIsSharedException() noexcept override {}
420 protected:
421 std::ostream & dumpOn( std::ostream & str ) const override;
422 private:
423 std::string _name;
424 };
425
427 {
428 public:
430 : MediaException("Can't eject any media")
431 , _name("")
432 {}
433
434 MediaNotEjectedException(std::string name)
435 : MediaException("Can't eject media")
436 , _name(std::move(name))
437 {}
438 ~MediaNotEjectedException() noexcept override {}
439 protected:
440 std::ostream & dumpOn( std::ostream & str ) const override;
441 private:
442 std::string _name;
443 };
444
446 {
447 public:
449 : MediaException("Unauthorized media access")
450 , _url("")
451 , _err("")
452 , _hint("")
453 {}
454
456 const std::string &msg_r,
457 std::string err_r,
458 std::string hint_r)
459 : MediaException(msg_r)
460 , _url(std::move(url_r))
461 , _err(std::move(err_r))
462 , _hint(std::move(hint_r))
463 {}
464
465 ~MediaUnauthorizedException() noexcept override {}
466
467 const Url & url() const { return _url; }
468 const std::string & err() const { return _err; }
470 const std::string & hint() const { return _hint; }
471
472 protected:
473 std::ostream & dumpOn( std::ostream & str ) const override;
474 private:
476 std::string _err;
477 std::string _hint;
478 };
479
481 {
482 public:
483 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
485 , _url(url_r.asString()), _msg(msg)
486 {}
487 ~MediaForbiddenException() noexcept override {}
488 protected:
489 std::ostream & dumpOn( std::ostream & str ) const override;
490 std::string _url;
491 std::string _msg;
492 };
493
495 {
496 public:
497 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
499 , _url(url_r.asString()), _msg(msg)
500 {}
501 ~MediaTimeoutException() noexcept override {}
502 protected:
503 std::ostream & dumpOn( std::ostream & str ) const override;
504 std::string _url;
505 std::string _msg;
506 };
507
509 {
510 public:
511 MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
513 , _url(url_r.asString())
514 , _msg(msg)
515 , _expectedFileSize(cnt_r)
516 {}
517 ~MediaFileSizeExceededException() noexcept override {}
518 protected:
519 std::ostream & dumpOn( std::ostream & str ) const override;
520 std::string _url;
521 std::string _msg;
523 };
524
527 {
528 public:
529 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
531 , _url(url_r.asString()), _msg(msg)
532 {}
533 ~MediaTemporaryProblemException() noexcept override {}
534 protected:
535 std::ostream & dumpOn( std::ostream & str ) const override;
536 std::string _url;
537 std::string _msg;
538 };
539
541 {
542 public:
543 MediaBadCAException(const Url & url_r, const std::string & msg = "")
545 , _url(url_r.asString()), _msg(msg)
546 {}
547 ~MediaBadCAException() noexcept override {}
548 protected:
549 std::ostream & dumpOn( std::ostream & str ) const override;
550 std::string _url;
551 std::string _msg;
552 };
553
555 {
556 public:
557 MediaInvalidCredentialsException( const std::string & msg = "" )
559 {}
561 };
562
564 {
565 public:
566 MediaRequestCancelledException( const std::string & msg = "" )
568 {}
569 ~MediaRequestCancelledException() noexcept override {}
570 };
571
573 } // namespace media
574} // namespace zypp
576#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
Store and operate with byte count.
Definition ByteCount.h:32
std::string asString() const
Error message provided by dumpOn as string.
Definition Exception.cc:111
Exception()
Default ctor.
Definition Exception.cc:81
const std::string & msg() const
Return the message string provided to the ctor.
Definition Exception.h:196
Url manipulation class.
Definition Url.h:93
MediaBadCAException(const Url &url_r, const std::string &msg="")
~MediaBadCAException() noexcept override
MediaBadFilenameException(std::string filename_r)
~MediaBadUrlException() noexcept override
MediaBadUrlException(const Url &url_r, std::string msg_r=std::string())
MediaCurlException(const Url &url_r, std::string err_r, std::string msg_r)
~MediaCurlException() noexcept override
~MediaCurlInitException() noexcept override
MediaCurlSetOptException(const Url &url_r, std::string msg_r)
~MediaCurlSetOptException() noexcept override
Just inherits Exception to separate media exceptions.
MediaException(const std::string &msg_r)
Ctor taking message.
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="")
MediaForbiddenException(const Url &url_r, const std::string &msg="")
~MediaForbiddenException() noexcept override
MediaInvalidCredentialsException(const std::string &msg="")
~MediaIsSharedException() noexcept override
MediaJammedException()
Ctor taking message.
~MediaJammedException() noexcept override
Dtor.
MediaMountException(std::string error_r, std::string source_r, std::string target_r, std::string cmdout_r="")
Ctor taking message.
const std::string & mountError() const
const std::string & mountSource() const
const std::string & mountTarget() const
const std::string & mountOutput() const
~MediaMountException() noexcept override
Dtor.
~MediaNotADirException() noexcept override
MediaNotADirException(const Url &url_r, const Pathname &path_r)
MediaNotAFileException(const Url &url_r, const Pathname &path_r)
~MediaNotAFileException() noexcept override
~MediaNotDesiredException() noexcept override
~MediaNotEjectedException() noexcept override
~MediaNotOpenException() noexcept override
MediaNotOpenException(std::string action_r)
MediaRequestCancelledException(const std::string &msg="")
MediaSystemException(const Url &url_r, std::string message_r)
~MediaSystemException() noexcept override
MediaTemporaryProblemException(const Url &url_r, const std::string &msg="")
~MediaTimeoutException() noexcept override
MediaTimeoutException(const Url &url_r, const std::string &msg="")
MediaUnauthorizedException(Url url_r, const std::string &msg_r, std::string err_r, std::string hint_r)
const std::string & hint() const
comma separated list of available authentication types
~MediaUnmountException() noexcept override
Dtor.
MediaUnmountException(std::string error_r, std::string path_r)
Ctor taking message.
~MediaWriteException() noexcept override
MediaWriteException(const Pathname &filename_r)
Definition Arch.h:364
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247