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