OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 , m_isolate(isolate) { } | 74 , m_isolate(isolate) { } |
75 | 75 |
76 ExceptionState(ContextType context, const char* interfaceName, const v8::Loc
al<v8::Object>& creationContext, v8::Isolate* isolate) | 76 ExceptionState(ContextType context, const char* interfaceName, const v8::Loc
al<v8::Object>& creationContext, v8::Isolate* isolate) |
77 : m_code(0) | 77 : m_code(0) |
78 , m_context(context) | 78 , m_context(context) |
79 , m_propertyName(0) | 79 , m_propertyName(0) |
80 , m_interfaceName(interfaceName) | 80 , m_interfaceName(interfaceName) |
81 , m_creationContext(creationContext) | 81 , m_creationContext(creationContext) |
82 , m_isolate(isolate) { ASSERT(m_context == ConstructionContext || m_cont
ext == EnumerationContext || m_context == IndexedSetterContext || m_context == I
ndexedGetterContext || m_context == IndexedDeletionContext); } | 82 , m_isolate(isolate) { ASSERT(m_context == ConstructionContext || m_cont
ext == EnumerationContext || m_context == IndexedSetterContext || m_context == I
ndexedGetterContext || m_context == IndexedDeletionContext); } |
83 | 83 |
| 84 ~ExceptionState(); |
| 85 |
84 virtual void throwDOMException(const ExceptionCode&, const String& message); | 86 virtual void throwDOMException(const ExceptionCode&, const String& message); |
85 virtual void throwTypeError(const String& message); | 87 virtual void throwTypeError(const String& message); |
86 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()); | 88 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()); |
87 virtual void throwRangeError(const String& message); | 89 virtual void throwRangeError(const String& message); |
88 | 90 |
89 bool hadException() const { return !m_exception.isEmpty() || m_code; } | 91 bool hadException() const { return !m_exception.isEmpty() || m_code; } |
90 void clearException(); | 92 void clearException(); |
91 | 93 |
92 ExceptionCode code() const { return m_code; } | 94 ExceptionCode code() const { return m_code; } |
93 const String& message() const { return m_message; } | 95 const String& message() const { return m_message; } |
94 | 96 |
95 bool throwIfNeeded() | |
96 { | |
97 if (!hadException()) | |
98 return false; | |
99 throwException(); | |
100 return true; | |
101 } | |
102 | |
103 // This method clears out the exception which |this| has. | 97 // This method clears out the exception which |this| has. |
104 ScriptPromise reject(ScriptState*); | 98 ScriptPromise reject(ScriptState*); |
105 | 99 |
106 // This method clears out the exception which |this| has. | 100 // This method clears out the exception which |this| has. |
107 void reject(ScriptPromiseResolver*); | 101 void reject(ScriptPromiseResolver*); |
108 | 102 |
109 ContextType context() const { return m_context; } | 103 ContextType context() const { return m_context; } |
110 const char* propertyName() const { return m_propertyName; } | 104 const char* propertyName() const { return m_propertyName; } |
111 const char* interfaceName() const { return m_interfaceName; } | 105 const char* interfaceName() const { return m_interfaceName; } |
112 | 106 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } | 155 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } |
162 void throwDOMException(const ExceptionCode&, const String& message) override
; | 156 void throwDOMException(const ExceptionCode&, const String& message) override
; |
163 void throwTypeError(const String& message = String()) override; | 157 void throwTypeError(const String& message = String()) override; |
164 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; | 158 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; |
165 void throwRangeError(const String& message) override; | 159 void throwRangeError(const String& message) override; |
166 }; | 160 }; |
167 | 161 |
168 } // namespace blink | 162 } // namespace blink |
169 | 163 |
170 #endif // ExceptionState_h | 164 #endif // ExceptionState_h |
OLD | NEW |