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 WRT_DOM_EXCEPTION_FACTORY_H_
17 #define WRT_DOM_EXCEPTION_FACTORY_H_
20 #include <dpl/noncopyable.h>
21 #include <JavaScriptCore/JavaScript.h>
23 namespace WrtDeviceApis {
24 namespace CommonsJavaScript {
26 #define DECLARE_JS_EXCEPTION_FACTORY(Class) static JSDOMExceptionFactory Class
28 class JSDOMExceptionFactory : public DPL::Noncopyable
31 DECLARE_JS_EXCEPTION_FACTORY(UnknownException);
32 DECLARE_JS_EXCEPTION_FACTORY(IndexSizeException);
33 DECLARE_JS_EXCEPTION_FACTORY(DomstringSizeException);
34 DECLARE_JS_EXCEPTION_FACTORY(HierarchyRequestException);
35 DECLARE_JS_EXCEPTION_FACTORY(WrongDocumentException);
36 DECLARE_JS_EXCEPTION_FACTORY(InvalidCharacterException);
37 DECLARE_JS_EXCEPTION_FACTORY(NoDataAllowedException);
38 DECLARE_JS_EXCEPTION_FACTORY(NoModificationAllowedException);
39 DECLARE_JS_EXCEPTION_FACTORY(NotFoundException);
40 DECLARE_JS_EXCEPTION_FACTORY(NotSupportedException);
41 DECLARE_JS_EXCEPTION_FACTORY(InuseAttributeException);
42 DECLARE_JS_EXCEPTION_FACTORY(InvalidStateException);
43 DECLARE_JS_EXCEPTION_FACTORY(SyntaxException);
44 DECLARE_JS_EXCEPTION_FACTORY(InvalidModificationException);
45 DECLARE_JS_EXCEPTION_FACTORY(NamespaceException);
46 DECLARE_JS_EXCEPTION_FACTORY(InvalidAccessException);
47 DECLARE_JS_EXCEPTION_FACTORY(ValidationException);
48 DECLARE_JS_EXCEPTION_FACTORY(TypeMismatchException);
49 DECLARE_JS_EXCEPTION_FACTORY(SecurityException);
50 DECLARE_JS_EXCEPTION_FACTORY(NetworkException);
51 DECLARE_JS_EXCEPTION_FACTORY(AbortException);
52 DECLARE_JS_EXCEPTION_FACTORY(TimeoutException);
53 DECLARE_JS_EXCEPTION_FACTORY(InvalidValuesException);
54 DECLARE_JS_EXCEPTION_FACTORY(IOException);
55 DECLARE_JS_EXCEPTION_FACTORY(QuotaExceededException);
58 explicit JSDOMExceptionFactory(int code);
61 * Creates exception object.
62 * @param context JS context of the exception.
63 * @param[out] exception Result object to which exception will be assigned.
64 * @return JS undefined value.
66 * JSValueRef JSClass::getProperty(JSContextRef context,
68 * JSStringRef propertyName,
69 * JSValueRef* exception)
72 * return JSExceptionFactory::InvalidArgumentException.make(context, exception);
77 JSValueRef make(JSContextRef context,
78 JSValueRef* exception,
79 const std::string& message = std::string());
82 * Creates exception object.
83 * @param context JS context of the exception.
84 * @return JS exception object.
86 * JSObjectRef jsError = JSExceptionFactory::InvalidArgumentException.make(context);
89 JSObjectRef make(JSContextRef context,
90 const std::string& message = std::string());
96 } // CommonsJavaScript