libzypp 8.13.6
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H 00013 #define ZYPP_MEDIA_MEDIAEXCEPTION_H 00014 00015 #include <iosfwd> 00016 00017 #include <string> 00018 #include <vector> 00019 00020 #include "zypp/base/Exception.h" 00021 #include "zypp/Pathname.h" 00022 #include "zypp/Url.h" 00023 00025 namespace zypp 00026 { 00027 namespace media { 00029 // 00030 // CLASS NAME : MediaException 00034 class MediaException : public Exception 00035 { 00036 public: 00040 MediaException() : Exception( "Media Exception" ) 00041 {} 00045 MediaException( const std::string & msg_r ) 00046 : Exception( msg_r ) 00047 {} 00048 00050 virtual ~MediaException() throw() {}; 00051 }; 00052 00053 class MediaMountException : public MediaException 00054 { 00055 public: 00056 MediaMountException() 00057 : MediaException( "Media Mount Exception" ) 00058 {} 00059 00063 MediaMountException( const std::string & error_r, 00064 const std::string & source_r, 00065 const std::string & target_r, 00066 const std::string & cmdout_r="") 00067 : MediaException() 00068 , _error(error_r) 00069 , _source(source_r) 00070 , _target(target_r) 00071 , _cmdout(cmdout_r) 00072 {} 00074 virtual ~MediaMountException() throw() {}; 00075 00076 const std::string & mountError() const 00077 { return _error; } 00078 const std::string & mountSource() const 00079 { return _source; } 00080 const std::string & mountTarget() const 00081 { return _target; } 00082 const std::string & mountOutput() const 00083 { return _cmdout; } 00084 00085 protected: 00086 virtual std::ostream & dumpOn( std::ostream & str ) const; 00087 private: 00088 std::string _error; 00089 std::string _source; 00090 std::string _target; 00091 std::string _cmdout; 00092 }; 00093 00094 class MediaUnmountException : public MediaException 00095 { 00096 public: 00100 MediaUnmountException( const std::string & error_r, 00101 const std::string & path_r ) 00102 : MediaException() 00103 , _error(error_r) 00104 , _path(path_r) 00105 {} 00107 virtual ~MediaUnmountException() throw() {}; 00108 protected: 00109 virtual std::ostream & dumpOn( std::ostream & str ) const; 00110 private: 00111 std::string _error; 00112 std::string _path; 00113 }; 00114 00115 class MediaBadFilenameException : public MediaException 00116 { 00117 public: 00118 MediaBadFilenameException(const std::string & filename_r) 00119 : MediaException() 00120 , _filename(filename_r) 00121 {} 00122 virtual ~MediaBadFilenameException() throw() {}; 00123 std::string filename() const { return _filename; } 00124 protected: 00125 virtual std::ostream & dumpOn( std::ostream & str ) const; 00126 private: 00127 std::string _filename; 00128 }; 00129 00130 class MediaNotOpenException : public MediaException 00131 { 00132 public: 00133 MediaNotOpenException(const std::string & action_r) 00134 : MediaException() 00135 , _action(action_r) 00136 {} 00137 virtual ~MediaNotOpenException() throw() {}; 00138 protected: 00139 virtual std::ostream & dumpOn( std::ostream & str ) const; 00140 private: 00141 std::string _action; 00142 }; 00143 00144 class MediaFileNotFoundException : public MediaException 00145 { 00146 public: 00147 MediaFileNotFoundException(const Url & url_r, 00148 const Pathname & filename_r) 00149 : MediaException() 00150 , _url(url_r.asString()) 00151 , _filename(filename_r.asString()) 00152 {} 00153 virtual ~MediaFileNotFoundException() throw() {}; 00154 protected: 00155 virtual std::ostream & dumpOn( std::ostream & str ) const; 00156 private: 00157 std::string _url; 00158 std::string _filename; 00159 }; 00160 00161 class MediaWriteException : public MediaException 00162 { 00163 public: 00164 MediaWriteException(const Pathname & filename_r) 00165 : MediaException() 00166 , _filename(filename_r.asString()) 00167 {} 00168 virtual ~MediaWriteException() throw() {}; 00169 protected: 00170 virtual std::ostream & dumpOn( std::ostream & str ) const; 00171 private: 00172 std::string _filename; 00173 }; 00174 00175 class MediaNotAttachedException : public MediaException 00176 { 00177 public: 00178 MediaNotAttachedException(const Url & url_r) 00179 : MediaException() 00180 , _url(url_r.asString()) 00181 {} 00182 virtual ~MediaNotAttachedException() throw() {}; 00183 protected: 00184 virtual std::ostream & dumpOn( std::ostream & str ) const; 00185 private: 00186 std::string _url; 00187 }; 00188 00189 class MediaBadAttachPointException : public MediaException 00190 { 00191 public: 00192 MediaBadAttachPointException(const Url & url_r) 00193 : MediaException() 00194 , _url(url_r.asString()) 00195 {} 00196 virtual ~MediaBadAttachPointException() throw() {}; 00197 protected: 00198 virtual std::ostream & dumpOn( std::ostream & str ) const; 00199 private: 00200 std::string _url; 00201 }; 00202 00203 class MediaCurlInitException : public MediaException 00204 { 00205 public: 00206 MediaCurlInitException(const Url & url_r) 00207 : MediaException() 00208 , _url(url_r.asString()) 00209 {} 00210 virtual ~MediaCurlInitException() throw() {}; 00211 protected: 00212 virtual std::ostream & dumpOn( std::ostream & str ) const; 00213 private: 00214 std::string _url; 00215 }; 00216 00217 class MediaMetalinkInitException : public MediaException 00218 { 00219 public: 00220 MediaMetalinkInitException(const Url & url_r) 00221 : MediaException() 00222 , _url(url_r.asString()) 00223 {} 00224 virtual ~MediaMetalinkInitException() throw() {}; 00225 protected: 00226 virtual std::ostream & dumpOn( std::ostream & str ) const; 00227 private: 00228 std::string _url; 00229 }; 00230 00231 class MediaAria2cInitException : public MediaException 00232 { 00233 public: 00234 MediaAria2cInitException(const Url & url_r) 00235 : MediaException() 00236 , _url(url_r.asString()) 00237 {} 00238 virtual ~MediaAria2cInitException() throw() {}; 00239 protected: 00240 virtual std::ostream & dumpOn( std::ostream & str ) const; 00241 private: 00242 std::string _url; 00243 }; 00244 00245 class MediaSystemException : public MediaException 00246 { 00247 public: 00248 MediaSystemException(const Url & url_r, 00249 const std::string & message_r) 00250 : MediaException() 00251 , _url(url_r.asString()) 00252 , _message(message_r) 00253 {} 00254 virtual ~MediaSystemException() throw() {}; 00255 protected: 00256 virtual std::ostream & dumpOn( std::ostream & str ) const; 00257 private: 00258 std::string _url; 00259 std::string _message; 00260 }; 00261 00262 class MediaNotAFileException : public MediaException 00263 { 00264 public: 00265 MediaNotAFileException(const Url & url_r, 00266 const Pathname & path_r) 00267 : MediaException() 00268 , _url(url_r.asString()) 00269 , _path(path_r.asString()) 00270 {} 00271 virtual ~MediaNotAFileException() throw() {}; 00272 protected: 00273 virtual std::ostream & dumpOn( std::ostream & str ) const; 00274 private: 00275 std::string _url; 00276 std::string _path; 00277 }; 00278 00279 class MediaNotADirException : public MediaException 00280 { 00281 public: 00282 MediaNotADirException(const Url & url_r, 00283 const Pathname & path_r) 00284 : MediaException() 00285 , _url(url_r.asString()) 00286 , _path(path_r.asString()) 00287 {} 00288 virtual ~MediaNotADirException() throw() {}; 00289 protected: 00290 virtual std::ostream & dumpOn( std::ostream & str ) const; 00291 private: 00292 std::string _url; 00293 std::string _path; 00294 }; 00295 00296 class MediaBadUrlException : public MediaException 00297 { 00298 public: 00299 MediaBadUrlException(const Url & url_r, 00300 const std::string &msg_r = std::string()) 00301 : MediaException() 00302 , _url(url_r.asString()) 00303 , _msg(msg_r) 00304 {} 00305 virtual ~MediaBadUrlException() throw() {}; 00306 protected: 00307 virtual std::ostream & dumpOn( std::ostream & str ) const; 00308 std::string _url; 00309 std::string _msg; 00310 }; 00311 00312 class MediaBadUrlEmptyHostException : public MediaBadUrlException 00313 { 00314 public: 00315 MediaBadUrlEmptyHostException(const Url & url_r) 00316 : MediaBadUrlException(url_r) 00317 {} 00318 virtual ~MediaBadUrlEmptyHostException() throw() {}; 00319 protected: 00320 virtual std::ostream & dumpOn( std::ostream & str ) const; 00321 }; 00322 00323 class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException 00324 { 00325 public: 00326 MediaBadUrlEmptyFilesystemException(const Url & url_r) 00327 : MediaBadUrlException(url_r) 00328 {} 00329 virtual ~MediaBadUrlEmptyFilesystemException() throw() {}; 00330 protected: 00331 virtual std::ostream & dumpOn( std::ostream & str ) const; 00332 }; 00333 00334 class MediaBadUrlEmptyDestinationException : public MediaBadUrlException 00335 { 00336 public: 00337 MediaBadUrlEmptyDestinationException(const Url & url_r) 00338 : MediaBadUrlException(url_r) 00339 {} 00340 virtual ~MediaBadUrlEmptyDestinationException() throw() {}; 00341 protected: 00342 virtual std::ostream & dumpOn( std::ostream & str ) const; 00343 }; 00344 00345 class MediaUnsupportedUrlSchemeException : public MediaBadUrlException 00346 { 00347 public: 00348 MediaUnsupportedUrlSchemeException(const Url & url_r) 00349 : MediaBadUrlException(url_r) 00350 {} 00351 virtual ~MediaUnsupportedUrlSchemeException() throw() {}; 00352 protected: 00353 virtual std::ostream & dumpOn( std::ostream & str ) const; 00354 }; 00355 00356 class MediaNotSupportedException : public MediaException 00357 { 00358 public: 00359 MediaNotSupportedException(const Url & url_r) 00360 : MediaException() 00361 , _url(url_r.asString()) 00362 {} 00363 virtual ~MediaNotSupportedException() throw() {}; 00364 protected: 00365 virtual std::ostream & dumpOn( std::ostream & str ) const; 00366 std::string _url; 00367 }; 00368 00369 class MediaCurlException : public MediaException 00370 { 00371 public: 00372 MediaCurlException(const Url & url_r, 00373 const std::string & err_r, 00374 const std::string & msg_r) 00375 : MediaException() 00376 , _url(url_r.asString()) 00377 , _err(err_r) 00378 , _msg(msg_r) 00379 {} 00380 virtual ~MediaCurlException() throw() {}; 00381 std::string errstr() const { return _err; } 00382 protected: 00383 virtual std::ostream & dumpOn( std::ostream & str ) const; 00384 std::string _url; 00385 std::string _err; 00386 std::string _msg; 00387 }; 00388 00389 class MediaCurlSetOptException : public MediaException 00390 { 00391 public: 00392 MediaCurlSetOptException(const Url & url_r, const std::string & msg_r) 00393 : MediaException() 00394 , _url(url_r.asString()) 00395 , _msg(msg_r) 00396 {} 00397 virtual ~MediaCurlSetOptException() throw() {}; 00398 protected: 00399 virtual std::ostream & dumpOn( std::ostream & str ) const; 00400 std::string _url; 00401 std::string _msg; 00402 }; 00403 00404 class MediaMetalinkException : public MediaException 00405 { 00406 public: 00407 MediaMetalinkException(const Url & url_r, 00408 const std::string & err_r, 00409 const std::string & msg_r) 00410 : MediaException() 00411 , _url(url_r.asString()) 00412 , _err(err_r) 00413 , _msg(msg_r) 00414 {} 00415 virtual ~MediaMetalinkException() throw() {}; 00416 protected: 00417 virtual std::ostream & dumpOn( std::ostream & str ) const; 00418 std::string _url; 00419 std::string _err; 00420 std::string _msg; 00421 }; 00422 00423 class MediaMetalinkSetOptException : public MediaException 00424 { 00425 public: 00426 MediaMetalinkSetOptException(const Url & url_r, const std::string & msg_r) 00427 : MediaException() 00428 , _url(url_r.asString()) 00429 , _msg(msg_r) 00430 {} 00431 virtual ~MediaMetalinkSetOptException() throw() {}; 00432 protected: 00433 virtual std::ostream & dumpOn( std::ostream & str ) const; 00434 std::string _url; 00435 std::string _msg; 00436 }; 00437 00438 class MediaAria2cException : public MediaException 00439 { 00440 public: 00441 MediaAria2cException(const Url & url_r, 00442 const std::string & err_r, 00443 const std::string & msg_r) 00444 : MediaException() 00445 , _url(url_r.asString()) 00446 , _err(err_r) 00447 , _msg(msg_r) 00448 {} 00449 virtual ~MediaAria2cException() throw() {}; 00450 protected: 00451 virtual std::ostream & dumpOn( std::ostream & str ) const; 00452 std::string _url; 00453 std::string _err; 00454 std::string _msg; 00455 }; 00456 00457 class MediaAria2cSetOptException : public MediaException 00458 { 00459 public: 00460 MediaAria2cSetOptException(const Url & url_r, const std::string & msg_r) 00461 : MediaException() 00462 , _url(url_r.asString()) 00463 , _msg(msg_r) 00464 {} 00465 virtual ~MediaAria2cSetOptException() throw() {}; 00466 protected: 00467 virtual std::ostream & dumpOn( std::ostream & str ) const; 00468 std::string _url; 00469 std::string _msg; 00470 }; 00471 00472 class MediaNotDesiredException : public MediaException 00473 { 00474 public: 00475 MediaNotDesiredException(const Url & url_r) 00476 : MediaException() 00477 , _url(url_r.asString()) 00478 {} 00479 virtual ~MediaNotDesiredException() throw() {}; 00480 protected: 00481 virtual std::ostream & dumpOn( std::ostream & str ) const; 00482 private: 00483 std::string _url; 00484 }; 00485 00486 class MediaIsSharedException : public MediaException 00487 { 00488 public: 00492 MediaIsSharedException(const std::string &name) 00493 : MediaException() 00494 , _name(name) 00495 {} 00496 virtual ~MediaIsSharedException() throw() {}; 00497 protected: 00498 virtual std::ostream & dumpOn( std::ostream & str ) const; 00499 private: 00500 std::string _name; 00501 }; 00502 00503 class MediaNotEjectedException: public MediaException 00504 { 00505 public: 00506 MediaNotEjectedException() 00507 : MediaException("Can't eject any media") 00508 , _name("") 00509 {} 00510 00511 MediaNotEjectedException(const std::string &name) 00512 : MediaException("Can't eject media") 00513 , _name(name) 00514 {} 00515 virtual ~MediaNotEjectedException() throw() {}; 00516 protected: 00517 virtual std::ostream & dumpOn( std::ostream & str ) const; 00518 private: 00519 std::string _name; 00520 }; 00521 00522 class MediaUnauthorizedException: public MediaException 00523 { 00524 public: 00525 MediaUnauthorizedException() 00526 : MediaException("Unauthorized media access") 00527 , _url("") 00528 , _err("") 00529 , _hint("") 00530 {} 00531 00532 MediaUnauthorizedException(const Url &url_r, 00533 const std::string &msg_r, 00534 const std::string &err_r, 00535 const std::string &hint_r) 00536 : MediaException(msg_r) 00537 , _url(url_r) 00538 , _err(err_r) 00539 , _hint(hint_r) 00540 {} 00541 00542 virtual ~MediaUnauthorizedException() throw() {}; 00543 00544 const Url & url() const { return _url; } 00545 const std::string & err() const { return _err; } 00547 const std::string & hint() const { return _hint; } 00548 00549 protected: 00550 virtual std::ostream & dumpOn( std::ostream & str ) const; 00551 private: 00552 Url _url; 00553 std::string _err; 00554 std::string _hint; 00555 }; 00556 00557 class MediaForbiddenException : public MediaException 00558 { 00559 public: 00560 MediaForbiddenException(const Url & url_r, const std::string & msg = "") 00561 : MediaException(msg) 00562 , _url(url_r.asString()), _msg(msg) 00563 {} 00564 virtual ~MediaForbiddenException() throw() {}; 00565 protected: 00566 virtual std::ostream & dumpOn( std::ostream & str ) const; 00567 std::string _url; 00568 std::string _msg; 00569 }; 00570 00571 class MediaTimeoutException : public MediaException 00572 { 00573 public: 00574 MediaTimeoutException(const Url & url_r, const std::string & msg = "") 00575 : MediaException(msg) 00576 , _url(url_r.asString()), _msg(msg) 00577 {} 00578 virtual ~MediaTimeoutException() throw() {}; 00579 protected: 00580 virtual std::ostream & dumpOn( std::ostream & str ) const; 00581 std::string _url; 00582 std::string _msg; 00583 }; 00584 00586 class MediaTemporaryProblemException : public MediaException 00587 { 00588 public: 00589 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "") 00590 : MediaException(msg) 00591 , _url(url_r.asString()), _msg(msg) 00592 {} 00593 virtual ~MediaTemporaryProblemException() throw() {}; 00594 protected: 00595 virtual std::ostream & dumpOn( std::ostream & str ) const; 00596 std::string _url; 00597 std::string _msg; 00598 }; 00599 00600 class MediaBadCAException : public MediaException 00601 { 00602 public: 00603 MediaBadCAException(const Url & url_r, const std::string & msg = "") 00604 : MediaException(msg) 00605 , _url(url_r.asString()), _msg(msg) 00606 {} 00607 virtual ~MediaBadCAException() throw() {}; 00608 protected: 00609 virtual std::ostream & dumpOn( std::ostream & str ) const; 00610 std::string _url; 00611 std::string _msg; 00612 }; 00613 00623 class MediaNoLoopDeviceException : public MediaException 00624 { 00625 public: 00626 MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "") 00627 : MediaException(msg) 00628 , _url(url_r.asString()), _msg(msg) 00629 {} 00630 virtual ~MediaNoLoopDeviceException() throw() {}; 00631 protected: 00632 virtual std::ostream & dumpOn( std::ostream & str ) const; 00633 std::string _url; 00634 std::string _msg; 00635 }; 00637 } // namespace media 00638 } // namespace zypp 00640 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H