added special exception class for aborting installation (#154936)
authorJiri Srain <jsrain@suse.cz>
Tue, 7 Mar 2006 18:12:17 +0000 (18:12 +0000)
committerJiri Srain <jsrain@suse.cz>
Tue, 7 Mar 2006 18:12:17 +0000 (18:12 +0000)
zypp/target/Makefile.am
zypp/target/TargetException.cc [new file with mode: 0644]
zypp/target/TargetException.h [new file with mode: 0644]
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index e5fcc2c..e0ac194 100644 (file)
@@ -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 (file)
index 0000000..341da74
--- /dev/null
@@ -0,0 +1,35 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/TargetException.cc
+ *
+*/
+
+#include <string>
+#include <iostream>
+
+#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 (file)
index 0000000..39ec002
--- /dev/null
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/TargetException.h
+ *
+*/
+#ifndef ZYPP_TARGET_TARGETEXCEPTION_H
+#define ZYPP_TARGET_TARGETEXCEPTION_H
+
+#include <iosfwd>
+
+#include <string>
+
+#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
index 95aa127..404c37e 100644 (file)
@@ -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;
     }
index 86f4b11..48b9426 100644 (file)
@@ -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