2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef WRTDEVICEAPIS_COMMONS_EXCEPTION_H_
17 #define WRTDEVICEAPIS_COMMONS_EXCEPTION_H_
19 #include <dpl/exception.h>
21 namespace WrtDeviceApis {
23 #define PLUGINS_DECLARE_EXCEPTION_TYPE(BaseClass, Class) \
27 ExceptionCodes::Enumeration m_code; \
29 virtual ExceptionCodes::Enumeration getCode() const { return m_code; } \
30 Class(const char *path, \
31 const char *function, \
33 const std::string & message = std::string()) : \
34 BaseClass(path, function, line, message) \
36 BaseClass::m_className = #Class; \
37 m_code = ExceptionCodes::Class; \
40 Class(const char *path, \
41 const char *function, \
43 const DPL::Exception & reason, \
44 const std::string & message = std::string()) : \
45 BaseClass(path, function, line, reason, message) \
47 BaseClass::m_className = #Class; \
48 m_code = ExceptionCodes::Class; \
59 InvalidArgumentException,
65 EventCancelledException,
66 EventWrongStateException,
69 PlatformWrongStateException,
70 PendingOperationException,
71 AlreadyInUseException,
72 CameraCaptureException,
73 CameraLiveVideoException,
74 LocalStorageValueNoModifableException,
82 PLUGINS_DECLARE_EXCEPTION_TYPE(DPL::Exception, Exception)
85 * Thrown when passed argument is not of expected type.
87 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, InvalidArgumentException)
90 * Thrown when type conversion is not possible.
92 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, ConversionException)
95 * Thrown when trying to operate on an object which is set to NULL.
97 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NullPointerException)
100 * Thrown when unknown error occured.
102 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnknownException)
105 * Thrown when platform function returned error code or threw an exception.
107 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PlatformException)
110 * Thrown when trying to access out of range element from array
112 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, OutOfRangeException)
115 * Thrown when trying to operate on cancelled event
117 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventCancelledException)
120 * Thrown when trying to operate on event in wrong state
122 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventWrongStateException)
125 * Thrown when trying to perform some action w/o proper permissions.
127 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, SecurityException)
130 * Thrown when trying to perform action that is not supported by current
133 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnsupportedException)
136 * Thrown when trying to perform action on platform in wrong state.
138 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PlatformWrongStateException)
141 * Thrown when trying to perform asynchronous action on JS object
142 * that already executes other asynchronous operation.
144 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PendingOperationException)
147 * Thrown when used camera is already in use.
149 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, AlreadyInUseException)
152 * Thrown when unpredicted error occurs while a picture or video is being
154 * or if endRecording is called while no video is currently captured.
156 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, CameraCaptureException)
159 * camera live video cannot be provided.
161 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, CameraLiveVideoException)
164 * Error trying to modify read only value
166 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, LocalStorageValueNoModifableException)
169 * Thrown when object is not found.
171 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NotFoundException)
173 } // WrtDeviceApisCommon
175 #endif /* WRTDEVICEAPIS_COMMONS_EXCEPTION_H_ */