Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / simulator / inc / simulator_exceptions.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 /**
22  * @file simulator_exceptions.h
23  *
24  * @brief This file provides exceptions which would be thrown from simualtor module.
25  *
26  */
27
28 #ifndef SIMULATOR_EXCEPTIONS_H_
29 #define SIMULATOR_EXCEPTIONS_H_
30
31 #include <exception>
32 #include "simulator_error_codes.h"
33
34 /**
35  * @class SimulatorException
36  * @brief This is the base exception of all type of exception thrown from simulator module.
37  */
38 class SimulatorException : public std::exception
39 {
40     public:
41         /**
42          * Constructor of SimulatorException.
43          *
44          * @param errorCode - Error code.
45          * @param message - String describing the error messsage.
46          */
47         SimulatorException(SimulatorResult errorCode, const std::string &message);
48
49         /**
50          * API to get error message describing exception reason.
51          *
52          * @return Null terminated string.
53          */
54         virtual const char *what() const noexcept;
55
56         /**
57          * API to get error code with which exception is thrown.
58          *
59          * @return SimulatorResult - Error code.
60          */
61         virtual SimulatorResult code() const;
62         virtual ~SimulatorException() throw() {}
63
64     private:
65         SimulatorResult m_errorCode;
66         std::string m_message;
67 };
68
69 /**
70  * @class InvalidArgsException
71  * @brief This exception will be thrown to indicate invalid arguments case.
72  */
73 class InvalidArgsException : public SimulatorException
74 {
75     public:
76         InvalidArgsException(SimulatorResult errorCode, const std::string &message);
77 };
78
79 /**
80  * @class NoSupportException
81  * @brief This exception will be thrown to indicate not supported operation cases.
82  */
83 class NoSupportException : public SimulatorException
84 {
85     public:
86         NoSupportException(const std::string &message);
87 };
88
89 /**
90  * @class OperationInProgressException
91  * @brief This exception will be thrown to indicate requested operation is not allowed as other operation
92  *              is in progress state.
93  */
94 class OperationInProgressException : public SimulatorException
95 {
96     public:
97         OperationInProgressException(const std::string &message);
98 };
99
100 #endif