OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 v8::Handle<v8::Value> V8ThrowException::createDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object
>& creationContext, v8::Isolate* isolate) | 47 v8::Handle<v8::Value> V8ThrowException::createDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object
>& creationContext, v8::Isolate* isolate) |
48 { | 48 { |
49 if (ec <= 0 || v8::V8::IsExecutionTerminating()) | 49 if (ec <= 0 || v8::V8::IsExecutionTerminating()) |
50 return v8Undefined(); | 50 return v8Undefined(); |
51 | 51 |
52 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); | 52 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); |
53 | 53 |
54 if (ec == V8GeneralError) | 54 if (ec == V8GeneralError) |
55 return V8ThrowException::createGeneralError(isolate, sanitizedMessage); | 55 return V8ThrowException::createGeneralError(isolate, sanitizedMessage); |
56 if (ec == V8TypeError) | 56 if (ec == V8TypeError) |
57 return V8ThrowException::createTypeError(sanitizedMessage, isolate); | 57 return V8ThrowException::createTypeError(isolate, sanitizedMessage); |
58 if (ec == V8RangeError) | 58 if (ec == V8RangeError) |
59 return V8ThrowException::createRangeError(sanitizedMessage, isolate); | 59 return V8ThrowException::createRangeError(isolate, sanitizedMessage); |
60 if (ec == V8SyntaxError) | 60 if (ec == V8SyntaxError) |
61 return V8ThrowException::createSyntaxError(isolate, sanitizedMessage); | 61 return V8ThrowException::createSyntaxError(isolate, sanitizedMessage); |
62 if (ec == V8ReferenceError) | 62 if (ec == V8ReferenceError) |
63 return V8ThrowException::createReferenceError(isolate, sanitizedMessage)
; | 63 return V8ThrowException::createReferenceError(isolate, sanitizedMessage)
; |
64 | 64 |
65 RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, san
itizedMessage, unsanitizedMessage); | 65 RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, san
itizedMessage, unsanitizedMessage); |
66 v8::Handle<v8::Value> exception = toV8(domException, creationContext, isolat
e); | 66 v8::Handle<v8::Value> exception = toV8(domException, creationContext, isolat
e); |
67 | 67 |
68 if (exception.IsEmpty()) | 68 if (exception.IsEmpty()) |
69 return v8Undefined(); | 69 return v8Undefined(); |
(...skipping 22 matching lines...) Expand all Loading... |
92 { | 92 { |
93 return v8::Exception::Error(v8String(isolate, message.isNull() ? "Error" : m
essage)); | 93 return v8::Exception::Error(v8String(isolate, message.isNull() ? "Error" : m
essage)); |
94 } | 94 } |
95 | 95 |
96 v8::Handle<v8::Value> V8ThrowException::throwGeneralError(v8::Isolate* isolate,
const String& message) | 96 v8::Handle<v8::Value> V8ThrowException::throwGeneralError(v8::Isolate* isolate,
const String& message) |
97 { | 97 { |
98 v8::Handle<v8::Value> exception = V8ThrowException::createGeneralError(isola
te, message); | 98 v8::Handle<v8::Value> exception = V8ThrowException::createGeneralError(isola
te, message); |
99 return V8ThrowException::throwException(exception, isolate); | 99 return V8ThrowException::throwException(exception, isolate); |
100 } | 100 } |
101 | 101 |
102 v8::Handle<v8::Value> V8ThrowException::createTypeError(const String& message, v
8::Isolate* isolate) | 102 v8::Handle<v8::Value> V8ThrowException::createTypeError(v8::Isolate* isolate, co
nst String& message) |
103 { | 103 { |
104 return v8::Exception::TypeError(v8String(isolate, message.isNull() ? "Type e
rror" : message)); | 104 return v8::Exception::TypeError(v8String(isolate, message.isNull() ? "Type e
rror" : message)); |
105 } | 105 } |
106 | 106 |
107 v8::Handle<v8::Value> V8ThrowException::throwTypeError(const String& message, v8
::Isolate* isolate) | 107 v8::Handle<v8::Value> V8ThrowException::throwTypeError(const String& message, v8
::Isolate* isolate) |
108 { | 108 { |
109 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(message,
isolate); | 109 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(isolate,
message); |
110 return V8ThrowException::throwException(exception, isolate); | 110 return V8ThrowException::throwException(exception, isolate); |
111 } | 111 } |
112 | 112 |
113 v8::Handle<v8::Value> V8ThrowException::createRangeError(const String& message,
v8::Isolate* isolate) | 113 v8::Handle<v8::Value> V8ThrowException::createRangeError(v8::Isolate* isolate, c
onst String& message) |
114 { | 114 { |
115 return v8::Exception::RangeError(v8String(isolate, message.isNull() ? "Range
error" : message)); | 115 return v8::Exception::RangeError(v8String(isolate, message.isNull() ? "Range
error" : message)); |
116 } | 116 } |
117 | 117 |
118 v8::Handle<v8::Value> V8ThrowException::throwRangeError(const String& message, v
8::Isolate* isolate) | 118 v8::Handle<v8::Value> V8ThrowException::throwRangeError(v8::Isolate* isolate, co
nst String& message) |
119 { | 119 { |
120 v8::Handle<v8::Value> exception = V8ThrowException::createRangeError(message
, isolate); | 120 v8::Handle<v8::Value> exception = V8ThrowException::createRangeError(isolate
, message); |
121 return V8ThrowException::throwException(exception, isolate); | 121 return V8ThrowException::throwException(exception, isolate); |
122 } | 122 } |
123 | 123 |
124 v8::Handle<v8::Value> V8ThrowException::createSyntaxError(v8::Isolate* isolate,
const String& message) | 124 v8::Handle<v8::Value> V8ThrowException::createSyntaxError(v8::Isolate* isolate,
const String& message) |
125 { | 125 { |
126 return v8::Exception::SyntaxError(v8String(isolate, message.isNull() ? "Synt
ax error" : message)); | 126 return v8::Exception::SyntaxError(v8String(isolate, message.isNull() ? "Synt
ax error" : message)); |
127 } | 127 } |
128 | 128 |
129 v8::Handle<v8::Value> V8ThrowException::throwSyntaxError(v8::Isolate* isolate, c
onst String& message) | 129 v8::Handle<v8::Value> V8ThrowException::throwSyntaxError(v8::Isolate* isolate, c
onst String& message) |
130 { | 130 { |
(...skipping 13 matching lines...) Expand all Loading... |
144 } | 144 } |
145 | 145 |
146 v8::Handle<v8::Value> V8ThrowException::throwException(v8::Handle<v8::Value> exc
eption, v8::Isolate* isolate) | 146 v8::Handle<v8::Value> V8ThrowException::throwException(v8::Handle<v8::Value> exc
eption, v8::Isolate* isolate) |
147 { | 147 { |
148 if (!v8::V8::IsExecutionTerminating()) | 148 if (!v8::V8::IsExecutionTerminating()) |
149 isolate->ThrowException(exception); | 149 isolate->ThrowException(exception); |
150 return v8::Undefined(isolate); | 150 return v8::Undefined(isolate); |
151 } | 151 } |
152 | 152 |
153 } // namespace blink | 153 } // namespace blink |
OLD | NEW |