Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / include / InitializeException.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5
6 #ifndef _INITIALIZE_EXCEPTION_H_
7 #define _INITIALIZE_EXCEPTION_H_
8
9 #include <stdexcept>
10 #include <ocstack.h>
11
12 namespace OC
13 {
14     class InitializeException : public std::exception
15     {
16     public:
17         InitializeException(const std::string& msg, OCStackResult reasonCode): m_errorMessage(msg), m_reason(reasonCode)
18         {
19         }
20
21         OCStackResult ReasonCode()
22         {
23             return m_reason;
24         }
25
26         std::string Message()
27         {
28             return m_errorMessage;
29         }
30
31         std::string Reason()
32         {
33             switch(m_reason)
34             {
35             case OC_STACK_OK:
36                 return "No Error";
37             case OC_STACK_INVALID_URI:
38                 return "Invalid URI";
39             case OC_STACK_INVALID_IP:
40                 return "Invalid IP";
41             case OC_STACK_INVALID_PORT:
42                 return "Invalid Port";
43             case OC_STACK_INVALID_CALLBACK:
44                 return "Invalid Callback";
45             case OC_STACK_INVALID_METHOD:
46                 return "Invalid Method";
47             case OC_STACK_ERROR:
48                 return "General Fault";
49             default:
50                 return "Unknown Error";
51             }
52         }
53
54     private:
55         const std::string& m_errorMessage;
56         OCStackResult m_reason;
57     };
58 }
59
60 #endif