Imported Upstream version 17.8.1
[platform/upstream/libzypp.git] / zypp / target / hal / HalException.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/hal/HalException.h
10  *
11  *  \brief Hardware abstaction layer library wrapper.
12  */
13 #ifndef ZYPP_TARGET_HAL_HALEXCEPTION_H
14 #define ZYPP_TARGET_HAL_HALEXCEPTION_H
15
16 #include "zypp/base/Exception.h"
17 #include "zypp/base/String.h"
18
19 //////////////////////////////////////////////////////////////////////
20 namespace zypp
21 { ////////////////////////////////////////////////////////////////////
22   ////////////////////////////////////////////////////////////////////
23   namespace target
24   { //////////////////////////////////////////////////////////////////
25     //////////////////////////////////////////////////////////////////
26     namespace hal
27     { ////////////////////////////////////////////////////////////////
28
29
30       ////////////////////////////////////////////////////////////////
31       //
32       // CLASS NAME : HalException
33       //
34       /** Hardware abstaction layer exception.
35        * Just inherits Exception to separate hal exceptions.
36        */
37       class HalException: public zypp::Exception
38       {
39       public:
40         /** Default constructor.
41          * Use \ref ZYPP_THROW to throw exceptions.
42          */
43         HalException();
44
45         /** Constructor taking complete hal error message.
46          * This constructor is used to generate custom error
47          * messages, in case, that no DBUS error is avaliable.
48          * Use \ref ZYPP_THROW to throw exceptions.
49          */
50         HalException(const std::string &msg_r);
51
52         /** Constructor taking HAL (DBUS) error message components.
53          * Use \ref ZYPP_THROW to throw exceptions.
54          */
55         HalException(const std::string &err_name, const std::string &err_msg);
56
57         /** Destructor.
58          */
59         virtual ~HalException() throw() {};
60
61         /**
62          * \return The HAL (DBUS) error name component.
63          */
64         const std::string & errorName() const
65         {
66           return e_name;
67         }
68
69         /**
70          * \return The HAL (DBUS) error message component.
71          */
72         const std::string & errorMessage() const
73         {
74           return e_msg;
75         }
76
77       protected:
78         virtual std::ostream & dumpOn( std::ostream & str ) const;
79
80       private:
81         std::string e_name;
82         std::string e_msg;
83       };
84
85       /** Exception thrown if we were built without hal support (-DNO_HAL).
86        */
87       struct NoHalException: public Exception
88       { NoHalException(); };
89
90       ////////////////////////////////////////////////////////////////
91     } // namespace hal
92     //////////////////////////////////////////////////////////////////
93     //////////////////////////////////////////////////////////////////
94   } // namespace target
95   ////////////////////////////////////////////////////////////////////
96   ////////////////////////////////////////////////////////////////////
97 } // namespace zypp
98 //////////////////////////////////////////////////////////////////////
99
100 #endif // ZYPP_TARGET_HAL_HALEXCEPTION_H
101
102 /*
103 ** vim: set ts=2 sts=2 sw=2 ai et:
104 */