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_
20 #include <dpl/exception.h>
22 namespace WrtDeviceApis {
24 #define PLUGINS_DECLARE_EXCEPTION_TYPE(BaseClass, Class) \
25 class Class : public BaseClass \
30 Class(const char *path, \
31 const char *function, \
33 const std::string & message = std::string()) : \
34 BaseClass(path, function, line, message) \
37 Class(const char *path, \
38 const char *function, \
40 const DPL::Exception & reason, \
41 const std::string & message = std::string()) : \
42 BaseClass(path, function, line, reason, message) \
45 virtual ::WrtDeviceApis::Commons::ExceptionCodes::Enumeration getCode() const \
47 return ::WrtDeviceApis::Commons::ExceptionCodes::Class; \
58 InvalidArgumentException,
64 EventCancelledException,
65 EventWrongStateException,
68 PlatformWrongStateException,
69 PendingOperationException,
70 AlreadyInUseException,
71 CameraCaptureException,
72 CameraLiveVideoException,
73 LocalStorageValueNoModifableException,
81 PLUGINS_DECLARE_EXCEPTION_TYPE(DPL::Exception, Exception)
84 * Thrown when passed argument is not of expected type.
86 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, InvalidArgumentException)
89 * Thrown when type conversion is not possible.
91 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, ConversionException)
94 * Thrown when trying to operate on an object which is set to NULL.
96 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NullPointerException)
99 * Thrown when unknown error occured.
101 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnknownException)
104 * Thrown when platform function returned error code or threw an exception.
106 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PlatformException)
109 * Thrown when trying to access out of range element from array
111 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, OutOfRangeException)
114 * Thrown when trying to operate on cancelled event
116 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventCancelledException)
119 * Thrown when trying to operate on event in wrong state
121 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, EventWrongStateException)
124 * Thrown when trying to perform some action w/o proper permissions.
126 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, SecurityException)
129 * Thrown when trying to perform action that is not supported by current
132 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnsupportedException)
135 * Thrown when trying to perform action on platform in wrong state.
137 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PlatformWrongStateException)
140 * Thrown when trying to perform asynchronous action on JS object
141 * that already executes other asynchronous operation.
143 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, PendingOperationException)
146 * Thrown when used camera is already in use.
148 PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, AlreadyInUseException)
151 * Thrown when unpredicted error occurs while a picture or video is being
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)
172 } // WrtDeviceApisCommon
174 #endif /* WRTDEVICEAPIS_COMMONS_EXCEPTION_H_ */