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 {
24 #define PLUGINS_DECLARE_EXCEPTION_TYPE(BaseClass, Class) \
28 ExceptionCodes::Enumeration m_code; \
30 virtual ExceptionCodes::Enumeration getCode() const { return m_code; } \
31 Class(const char *path, \
32 const char *function, \
34 const std::string & message = std::string()) : \
35 BaseClass(path, function, line, message) \
37 BaseClass::m_className = # Class; \
38 m_code = ExceptionCodes::Class; \
41 Class(const char *path, \
42 const char *function, \
44 const DPL::Exception & reason, \
45 const std::string & message = std::string()) : \
46 BaseClass(path, function, line, reason, message) \
48 BaseClass::m_className = # Class; \
49 m_code = ExceptionCodes::Class; \
60 InvalidArgumentException,
66 EventCancelledException,
67 EventWrongStateException,
70 PlatformWrongStateException,
71 PendingOperationException,
72 AlreadyInUseException,
73 CameraCaptureException,
74 CameraLiveVideoException,
75 LocalStorageValueNoModifableException,
83 PLUGINS_DECLARE_EXCEPTION_TYPE(DPL::Exception, Exception)
86 * Thrown when passed argument is not of expected type.
88 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, InvalidArgumentException)
91 * Thrown when type conversion is not possible.
93 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, ConversionException)
96 * Thrown when trying to operate on an object which is set to NULL.
98 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NullPointerException)
101 * Thrown when unknown error occured.
103 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnknownException)
106 * Thrown when platform function returned error code or threw an exception.
108 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PlatformException)
111 * Thrown when trying to access out of range element from array
113 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, OutOfRangeException)
116 * Thrown when trying to operate on cancelled event
118 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventCancelledException)
121 * Thrown when trying to operate on event in wrong state
123 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventWrongStateException)
126 * Thrown when trying to perform some action w/o proper permissions.
128 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, SecurityException)
131 * Thrown when trying to perform action that is not supported by current platform.
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 captured
153 * or if endRecording is called while no video is currently captured.
155 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, CameraCaptureException)
158 * camera live video cannot be provided.
160 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, CameraLiveVideoException)
163 * Error trying to modify read only value
165 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, LocalStorageValueNoModifableException)
168 * Thrown when object is not found.
170 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NotFoundException)
173 } // WrtDeviceApisCommon
175 #endif /* WRTDEVICEAPIS_COMMONS_EXCEPTION_H_ */