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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
32 | 32 |
33 #include "bindings/core/v8/ExceptionMessages.h" | 33 #include "bindings/core/v8/ExceptionMessages.h" |
34 #include "bindings/core/v8/ScriptPromiseResolver.h" | 34 #include "bindings/core/v8/ScriptPromiseResolver.h" |
35 #include "bindings/core/v8/V8ThrowException.h" | 35 #include "bindings/core/v8/V8ThrowException.h" |
36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
| 40 ExceptionState::~ExceptionState() |
| 41 { |
| 42 if (!m_exception.isEmpty()) |
| 43 throwException(); |
| 44 } |
| 45 |
40 void ExceptionState::clearException() | 46 void ExceptionState::clearException() |
41 { | 47 { |
42 m_code = 0; | 48 m_code = 0; |
43 m_exception.clear(); | 49 m_exception.clear(); |
44 } | 50 } |
45 | 51 |
46 ScriptPromise ExceptionState::reject(ScriptState* scriptState) | 52 ScriptPromise ExceptionState::reject(ScriptState* scriptState) |
47 { | 53 { |
48 ScriptPromise promise = ScriptPromise::reject(scriptState, m_exception.newLo
cal(scriptState->isolate())); | 54 ScriptPromise promise = ScriptPromise::reject(scriptState, m_exception.newLo
cal(scriptState->isolate())); |
| 55 throwException(); |
49 clearException(); | 56 clearException(); |
50 return promise; | 57 return promise; |
51 } | 58 } |
52 | 59 |
53 void ExceptionState::reject(ScriptPromiseResolver* resolver) | 60 void ExceptionState::reject(ScriptPromiseResolver* resolver) |
54 { | 61 { |
55 resolver->reject(m_exception.newLocal(resolver->getScriptState()->isolate())
); | 62 resolver->reject(m_exception.newLocal(resolver->getScriptState()->isolate())
); |
| 63 throwException(); |
56 clearException(); | 64 clearException(); |
57 } | 65 } |
58 | 66 |
59 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
ssage) | 67 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
ssage) |
60 { | 68 { |
61 ASSERT(ec); | 69 ASSERT(ec); |
62 ASSERT(m_isolate); | 70 ASSERT(m_isolate); |
63 ASSERT(!m_creationContext.IsEmpty()); | 71 ASSERT(!m_creationContext.IsEmpty()); |
64 | 72 |
65 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. | 73 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. |
(...skipping 25 matching lines...) Expand all Loading... |
91 return; | 99 return; |
92 } | 100 } |
93 | 101 |
94 m_exception.set(m_isolate, exception); | 102 m_exception.set(m_isolate, exception); |
95 } | 103 } |
96 | 104 |
97 void ExceptionState::throwException() | 105 void ExceptionState::throwException() |
98 { | 106 { |
99 ASSERT(!m_exception.isEmpty()); | 107 ASSERT(!m_exception.isEmpty()); |
100 V8ThrowException::throwException(m_exception.newLocal(m_isolate), m_isolate)
; | 108 V8ThrowException::throwException(m_exception.newLocal(m_isolate), m_isolate)
; |
| 109 clearException(); |
101 } | 110 } |
102 | 111 |
103 void ExceptionState::throwTypeError(const String& message) | 112 void ExceptionState::throwTypeError(const String& message) |
104 { | 113 { |
105 ASSERT(m_isolate); | 114 ASSERT(m_isolate); |
106 m_code = V8TypeError; | 115 m_code = V8TypeError; |
107 m_message = message; | 116 m_message = message; |
108 setException(V8ThrowException::createTypeError(m_isolate, addExceptionContex
t(message))); | 117 setException(V8ThrowException::createTypeError(m_isolate, addExceptionContex
t(message))); |
109 } | 118 } |
110 | 119 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac
eName(), message); | 201 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac
eName(), message); |
193 else if (m_context == IndexedGetterContext) | 202 else if (m_context == IndexedGetterContext) |
194 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa
me(), message); | 203 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa
me(), message); |
195 else if (m_context == IndexedSetterContext) | 204 else if (m_context == IndexedSetterContext) |
196 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa
me(), message); | 205 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa
me(), message); |
197 } | 206 } |
198 return processedMessage; | 207 return processedMessage; |
199 } | 208 } |
200 | 209 |
201 } // namespace blink | 210 } // namespace blink |
OLD | NEW |