00001
00002
00003
00004
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
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 protected:
00382 virtual std::ostream & dumpOn( std::ostream & str ) const;
00383 std::string _url;
00384 std::string _err;
00385 std::string _msg;
00386 };
00387
00388 class MediaCurlSetOptException : public MediaException
00389 {
00390 public:
00391 MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
00392 : MediaException()
00393 , _url(url_r.asString())
00394 , _msg(msg_r)
00395 {}
00396 virtual ~MediaCurlSetOptException() throw() {};
00397 protected:
00398 virtual std::ostream & dumpOn( std::ostream & str ) const;
00399 std::string _url;
00400 std::string _msg;
00401 };
00402
00403 class MediaMetalinkException : public MediaException
00404 {
00405 public:
00406 MediaMetalinkException(const Url & url_r,
00407 const std::string & err_r,
00408 const std::string & msg_r)
00409 : MediaException()
00410 , _url(url_r.asString())
00411 , _err(err_r)
00412 , _msg(msg_r)
00413 {}
00414 virtual ~MediaMetalinkException() throw() {};
00415 protected:
00416 virtual std::ostream & dumpOn( std::ostream & str ) const;
00417 std::string _url;
00418 std::string _err;
00419 std::string _msg;
00420 };
00421
00422 class MediaMetalinkSetOptException : public MediaException
00423 {
00424 public:
00425 MediaMetalinkSetOptException(const Url & url_r, const std::string & msg_r)
00426 : MediaException()
00427 , _url(url_r.asString())
00428 , _msg(msg_r)
00429 {}
00430 virtual ~MediaMetalinkSetOptException() throw() {};
00431 protected:
00432 virtual std::ostream & dumpOn( std::ostream & str ) const;
00433 std::string _url;
00434 std::string _msg;
00435 };
00436
00437 class MediaAria2cException : public MediaException
00438 {
00439 public:
00440 MediaAria2cException(const Url & url_r,
00441 const std::string & err_r,
00442 const std::string & msg_r)
00443 : MediaException()
00444 , _url(url_r.asString())
00445 , _err(err_r)
00446 , _msg(msg_r)
00447 {}
00448 virtual ~MediaAria2cException() throw() {};
00449 protected:
00450 virtual std::ostream & dumpOn( std::ostream & str ) const;
00451 std::string _url;
00452 std::string _err;
00453 std::string _msg;
00454 };
00455
00456 class MediaAria2cSetOptException : public MediaException
00457 {
00458 public:
00459 MediaAria2cSetOptException(const Url & url_r, const std::string & msg_r)
00460 : MediaException()
00461 , _url(url_r.asString())
00462 , _msg(msg_r)
00463 {}
00464 virtual ~MediaAria2cSetOptException() throw() {};
00465 protected:
00466 virtual std::ostream & dumpOn( std::ostream & str ) const;
00467 std::string _url;
00468 std::string _msg;
00469 };
00470
00471 class MediaNotDesiredException : public MediaException
00472 {
00473 public:
00474 MediaNotDesiredException(const Url & url_r)
00475 : MediaException()
00476 , _url(url_r.asString())
00477 {}
00478 virtual ~MediaNotDesiredException() throw() {};
00479 protected:
00480 virtual std::ostream & dumpOn( std::ostream & str ) const;
00481 private:
00482 std::string _url;
00483 };
00484
00485 class MediaIsSharedException : public MediaException
00486 {
00487 public:
00491 MediaIsSharedException(const std::string &name)
00492 : MediaException()
00493 , _name(name)
00494 {}
00495 virtual ~MediaIsSharedException() throw() {};
00496 protected:
00497 virtual std::ostream & dumpOn( std::ostream & str ) const;
00498 private:
00499 std::string _name;
00500 };
00501
00502 class MediaNotEjectedException: public MediaException
00503 {
00504 public:
00505 MediaNotEjectedException()
00506 : MediaException("Can't eject any media")
00507 , _name("")
00508 {}
00509
00510 MediaNotEjectedException(const std::string &name)
00511 : MediaException("Can't eject media")
00512 , _name(name)
00513 {}
00514 virtual ~MediaNotEjectedException() throw() {};
00515 protected:
00516 virtual std::ostream & dumpOn( std::ostream & str ) const;
00517 private:
00518 std::string _name;
00519 };
00520
00521 class MediaUnauthorizedException: public MediaException
00522 {
00523 public:
00524 MediaUnauthorizedException()
00525 : MediaException("Unauthorized media access")
00526 , _url("")
00527 , _err("")
00528 , _hint("")
00529 {}
00530
00531 MediaUnauthorizedException(const Url &url_r,
00532 const std::string &msg_r,
00533 const std::string &err_r,
00534 const std::string &hint_r)
00535 : MediaException(msg_r)
00536 , _url(url_r)
00537 , _err(err_r)
00538 , _hint(hint_r)
00539 {}
00540
00541 virtual ~MediaUnauthorizedException() throw() {};
00542
00543 const Url & url() const { return _url; }
00544 const std::string & err() const { return _err; }
00546 const std::string & hint() const { return _hint; }
00547
00548 protected:
00549 virtual std::ostream & dumpOn( std::ostream & str ) const;
00550 private:
00551 Url _url;
00552 std::string _err;
00553 std::string _hint;
00554 };
00555
00556 class MediaForbiddenException : public MediaException
00557 {
00558 public:
00559 MediaForbiddenException(const Url & url_r, const std::string & msg = "")
00560 : MediaException(msg)
00561 , _url(url_r.asString()), _msg(msg)
00562 {}
00563 virtual ~MediaForbiddenException() throw() {};
00564 protected:
00565 virtual std::ostream & dumpOn( std::ostream & str ) const;
00566 std::string _url;
00567 std::string _msg;
00568 };
00569
00570 class MediaTimeoutException : public MediaException
00571 {
00572 public:
00573 MediaTimeoutException(const Url & url_r, const std::string & msg = "")
00574 : MediaException(msg)
00575 , _url(url_r.asString()), _msg(msg)
00576 {}
00577 virtual ~MediaTimeoutException() throw() {};
00578 protected:
00579 virtual std::ostream & dumpOn( std::ostream & str ) const;
00580 std::string _url;
00581 std::string _msg;
00582 };
00583
00585 class MediaTemporaryProblemException : public MediaException
00586 {
00587 public:
00588 MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
00589 : MediaException(msg)
00590 , _url(url_r.asString()), _msg(msg)
00591 {}
00592 virtual ~MediaTemporaryProblemException() throw() {};
00593 protected:
00594 virtual std::ostream & dumpOn( std::ostream & str ) const;
00595 std::string _url;
00596 std::string _msg;
00597 };
00598
00599 class MediaBadCAException : public MediaException
00600 {
00601 public:
00602 MediaBadCAException(const Url & url_r, const std::string & msg = "")
00603 : MediaException(msg)
00604 , _url(url_r.asString()), _msg(msg)
00605 {}
00606 virtual ~MediaBadCAException() throw() {};
00607 protected:
00608 virtual std::ostream & dumpOn( std::ostream & str ) const;
00609 std::string _url;
00610 std::string _msg;
00611 };
00612
00622 class MediaNoLoopDeviceException : public MediaException
00623 {
00624 public:
00625 MediaNoLoopDeviceException(const Url & url_r, const std::string & msg = "")
00626 : MediaException(msg)
00627 , _url(url_r.asString()), _msg(msg)
00628 {}
00629 virtual ~MediaNoLoopDeviceException() throw() {};
00630 protected:
00631 virtual std::ostream & dumpOn( std::ostream & str ) const;
00632 std::string _url;
00633 std::string _msg;
00634 };
00636 }
00637 }
00639 #endif // ZYPP_MEDIA_MEDIAEXCEPTION_H