From 39b4e86e47443a9e613285135a58262990d1476f Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Tue, 7 Mar 2006 18:12:17 +0000 Subject: [PATCH] added special exception class for aborting installation (#154936) --- zypp/target/Makefile.am | 6 ++- zypp/target/TargetException.cc | 35 +++++++++++++++++ zypp/target/TargetException.h | 72 ++++++++++++++++++++++++++++++++++ zypp/target/TargetImpl.cc | 2 +- zypp/target/TargetImpl.h | 1 + 5 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 zypp/target/TargetException.cc create mode 100644 zypp/target/TargetException.h diff --git a/zypp/target/Makefile.am b/zypp/target/Makefile.am index e5fcc2c4f..e0ac194cf 100644 --- a/zypp/target/Makefile.am +++ b/zypp/target/Makefile.am @@ -11,7 +11,8 @@ targetincludedir = $(pkgincludedir)/target targetinclude_HEADERS = \ TargetImpl.h \ - TargetCallbackReceiver.h + TargetCallbackReceiver.h \ + TargetException.h ## ################################################## @@ -21,7 +22,8 @@ noinst_LTLIBRARIES = lib@PACKAGE@_target.la lib@PACKAGE@_target_la_SOURCES = \ TargetImpl.cc \ - TargetCallbackReceiver.cc + TargetCallbackReceiver.cc \ + TargetException.cc lib@PACKAGE@_target_la_LDFLAGS = @LIBZYPP_VERSION_INFO@ diff --git a/zypp/target/TargetException.cc b/zypp/target/TargetException.cc new file mode 100644 index 000000000..341da7450 --- /dev/null +++ b/zypp/target/TargetException.cc @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/TargetException.cc + * +*/ + +#include +#include + +#include "zypp/target/TargetException.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + namespace target { + ///////////////////////////////////////////////////////////////// + + std::ostream & TargetAbortedException::dumpOn( std::ostream & str ) const + { + return str << "Installation aborted by user" << endl; + } + + + ///////////////////////////////////////////////////////////////// + } // namespace target +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/target/TargetException.h b/zypp/target/TargetException.h new file mode 100644 index 000000000..39ec002aa --- /dev/null +++ b/zypp/target/TargetException.h @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/TargetException.h + * +*/ +#ifndef ZYPP_TARGET_TARGETEXCEPTION_H +#define ZYPP_TARGET_TARGETEXCEPTION_H + +#include + +#include + +#include "zypp/base/Exception.h" +#include "zypp/Pathname.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + namespace target { + /////////////////////////////////////////////////////////////// + // + // CLASS NAME : TargetException + /** Just inherits Exception to separate target exceptions + * + **/ + class TargetException : public Exception + { + public: + /** Ctor taking message. + * Use \ref ZYPP_THROW to throw exceptions. + */ + TargetException() + : Exception( "Target Exception" ) + {} + /** Ctor taking message. + * Use \ref ZYPP_THROW to throw exceptions. + */ + TargetException( const std::string & msg_r ) + : Exception( msg_r ) + {} + /** Dtor. */ + virtual ~TargetException() throw() {}; + }; + + class TargetAbortedException : public TargetException + { + public: + /** Ctor taking message. + * Use \ref ZYPP_THROW to throw exceptions. + */ + TargetAbortedException( const std::string & msg_r ) + : TargetException( msg_r ) + {} + /** Dtor. */ + virtual ~TargetAbortedException() throw() {}; + protected: + virtual std::ostream & dumpOn( std::ostream & str ) const; + private: + }; + + + ///////////////////////////////////////////////////////////////// + } // namespace target +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_TARGET_TARGETEXCEPTION_H diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 95aa127bc..404c37eda 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -370,7 +370,7 @@ namespace zypp } if( abort ) - ZYPP_THROW( Exception( N_("Target commit aborted by user.") ) ); + ZYPP_THROW( TargetAbortedException( N_("Target commit aborted by user.") ) ); return remaining; } diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index 86f4b1119..48b94268f 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -27,6 +27,7 @@ #include "zypp/Target.h" #include "zypp/target/rpm/RpmDb.h" #include "zypp/target/store/PersistentStorage.h" +#include "zypp/target/TargetException.h" /////////////////////////////////////////////////////////////////// namespace zypp -- 2.34.1