libzypp 17.37.17
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:
168 , _url(url_r.asString())
169 {}
171 const Pathname & filename_r)
173 , _url(url_r.asString())
174 , _filename(filename_r.asString())
175 {}
176 ~MediaFileNotFoundException() noexcept override {}
177 protected:
178 std::ostream & dumpOn( std::ostream & str ) const override;
179 private:
180 std::string _url;
181 std::string _filename;
182 };
183
185 {
186 public:
187 MediaWriteException(const Pathname & filename_r)
189 , _filename(filename_r.asString())
190 {}
191 ~MediaWriteException() noexcept override {}
192 protected:
193 std::ostream & dumpOn( std::ostream & str ) const override;
194 private:
195 std::string _filename;
196 };
197
199 {
200 public:
203 , _url(url_r.asString())
204 {}
205 ~MediaNotAttachedException() noexcept override {}
206 protected:
207 std::ostream & dumpOn( std::ostream & str ) const override;
208 private:
209 std::string _url;
210 };
211
213 {
214 public:
217 , _url(url_r.asString())
218 {}
219 ~MediaBadAttachPointException() noexcept override {}
220 protected:
221 std::ostream & dumpOn( std::ostream & str ) const override;
222 private:
223 std::string _url;
224 };
225
227 {
228 public:
231 , _url(url_r.asString())
232 {}
233 ~MediaCurlInitException() noexcept override {}
234 protected:
235 std::ostream & dumpOn( std::ostream & str ) const override;
236 private:
237 std::string _url;
238 };
239
241 {
242 public:
244 std::string message_r)
246 , _url(url_r.asString())
247 , _message(std::move(message_r))
248 {}
249 ~MediaSystemException() noexcept override {}
250 protected:
251 std::ostream & dumpOn( std::ostream & str ) const override;
252 private:
253 std::string _url;
254 std::string _message;
255 };
256
258 {
259 public:
261 const Pathname & path_r)
263 , _url(url_r.asString())
264 , _path(path_r.asString())
265 {}
266 ~MediaNotAFileException() noexcept override {}
267 protected:
268 std::ostream & dumpOn( std::ostream & str ) const override;
269 private:
270 std::string _url;
271 std::string _path;
272 };
273
275 {
276 public:
278 const Pathname & path_r)
280 , _url(url_r.asString())
281 , _path(path_r.asString())
282 {}
283 ~MediaNotADirException() noexcept override {}
284 protected:
285 std::ostream & dumpOn( std::ostream & str ) const override;
286 private:
287 std::string _url;
288 std::string _path;
289 };
290
292 {
293 public:
295 std::string msg_r = std::string())
297 , _url(url_r.asString())
298 , _msg(std::move(msg_r))
299 {}
300 ~MediaBadUrlException() noexcept override {}
301 protected:
302 std::ostream & dumpOn( std::ostream & str ) const override;
303 std::string _url;
304 std::string _msg;
305 };
306
308 {
309 public:
311 : MediaBadUrlException(url_r)
312 {}
313 ~MediaBadUrlEmptyHostException() noexcept override {}
314 protected:
315 std::ostream & dumpOn( std::ostream & str ) const override;
316 };
317
319 {
320 public:
325 protected:
326 std::ostream & dumpOn( std::ostream & str ) const override;
327 };
328
330 {
331 public:
336 protected:
337 std::ostream & dumpOn( std::ostream & str ) const override;
338 };
339
341 {
342 public:
347 protected:
348 std::ostream & dumpOn( std::ostream & str ) const override;
349 };
350
352 {
353 public:
356 , _url(url_r.asString())
357 {}
358 ~MediaNotSupportedException() noexcept override {}
359 protected:
360 std::ostream & dumpOn( std::ostream & str ) const override;
361 std::string _url;
362 };
363
365 {
366 public:
367 MediaCurlException(const Url & url_r,
368 std::string err_r,
369 std::string msg_r)
371 , _url(url_r.asString())
372 , _err(std::move(err_r))
373 , _msg(std::move(msg_r))
374 {}
375 ~MediaCurlException() noexcept override {}
376 std::string errstr() const { return _err; }
377 protected:
378 std::ostream & dumpOn( std::ostream & str ) const override;
379 std::string _url;
380 std::string _err;
381 std::string _msg;
382 };
383
385 {
386 public:
387 MediaCurlSetOptException(const Url & url_r, std::string msg_r)
389 , _url(url_r.asString())
390 , _msg(std::move(msg_r))
391 {}
392 ~MediaCurlSetOptException() noexcept override {}
393 protected:
394 std::ostream & dumpOn( std::ostream & str ) const override;
395 std::string _url;
396 std::string _msg;
397 };
398
400 {
401 public:
404 , _url(url_r.asString())
405 {}
406 ~MediaNotDesiredException() noexcept override {}
407 protected:
408 std::ostream & dumpOn( std::ostream & str ) const override;
409 private:
410 std::string _url;
411 };
412
414 {
415 public:
419 MediaIsSharedException(std::string name)
421 , _name(std::move(name))
422 {}
423 ~MediaIsSharedException() noexcept override {}
424 protected:
425 std::ostream & dumpOn( std::ostream & str ) const override;
426 private:
427 std::string _name;
428 };
429
431 {
432 public:
434 : MediaException("Can't eject any media")
435 , _name("")
436 {}
437
438 MediaNotEjectedException(std::string name)
439 : MediaException("Can't eject media")
440 , _name(std::move(name))
441 {}
442 ~MediaNotEjectedException() noexcept override {}
443 protected:
444 std::ostream & dumpOn( std::ostream & str ) const override;
445 private:
446 std::string _name;
447 };
448
450 {
451 public:
453 : MediaException("Unauthorized media access")
454 , _url("")
455 , _err("")
456 , _hint("")
457 {}
458
460 const std::string &msg_r,
461 std::string err_r,
462 std::string hint_r)
463 : MediaException(msg_r)
464 , _url(std::move(url_r))
465 , _err(std::move(err_r))
466 , _hint(std::move(hint_r))
467 {}
468
469 ~MediaUnauthorizedException() noexcept override {}
470
471 const Url & url() const { return _url; }
472 const std::string & err() const { return _err; }
474 const std::string & hint() const { return _hint; }
475
476 protected:
477 std::ostream & dumpOn( std::ostream & str ) const override;
478 private:
480 std::string _err;
481 std::string _hint;
482 };
483
485 {
486 public:
487 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
489 , _url(url_r.asString()), _msg(msg)
490 {}
491 ~MediaForbiddenException() noexcept override {}
492 protected:
493 std::ostream & dumpOn( std::ostream & str ) const override;
494 std::string _url;
495 std::string _msg;
496 };
497
499 {
500 public:
501 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
503 , _url(url_r.asString()), _msg(msg)
504 {}
505 ~MediaTimeoutException() noexcept override {}
506 protected:
507 std::ostream & dumpOn( std::ostream & str ) const override;
508 std::string _url;
509 std::string _msg;
510 };
511
513 {
514 public:
515 MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
517 , _url(url_r.asString())
518 , _msg(msg)
519 , _expectedFileSize(cnt_r)
520 {}
521 ~MediaFileSizeExceededException() noexcept override {}
522 protected:
523 std::ostream & dumpOn( std::ostream & str ) const override;
524 std::string _url;
525 std::string _msg;
527 };
528
531 {
532 public:
533 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
535 , _url(url_r.asString()), _msg(msg)
536 {}
537 ~MediaTemporaryProblemException() noexcept override {}
538 protected:
539 std::ostream & dumpOn( std::ostream & str ) const override;
540 std::string _url;
541 std::string _msg;
542 };
543
545 {
546 public:
547 MediaBadCAException(const Url & url_r, const std::string & msg = "")
549 , _url(url_r.asString()), _msg(msg)
550 {}
551 ~MediaBadCAException() noexcept override {}
552 protected:
553 std::ostream & dumpOn( std::ostream & str ) const override;
554 std::string _url;
555 std::string _msg;
556 };
557
559 {
560 public:
561 MediaInvalidCredentialsException( const std::string & msg = "" )
563 {}
565 };
566
568 {
569 public:
570 MediaRequestCancelledException( const std::string & msg = "" )
572 {}
573 ~MediaRequestCancelledException() noexcept override {}
574 };
575
577 } // namespace media
578} // namespace zypp
580#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:124
Exception()
Default ctor.
Definition Exception.cc:94
const std::string & msg() const
Return the message string provided to the ctor.
Definition Exception.h:206
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