| 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 26 matching lines...) Expand all Loading... |
| 37 ASSERT(info.Data()->IsObject()); | 37 ASSERT(info.Data()->IsObject()); |
| 38 v8SetReturnValue(info, info.Data()->ToObject()->Get(v8AtomicString(info.GetI
solate(), "stack"))); | 38 v8SetReturnValue(info, info.Data()->ToObject()->Get(v8AtomicString(info.GetI
solate(), "stack"))); |
| 39 } | 39 } |
| 40 | 40 |
| 41 static void domExceptionStackSetter(v8::Local<v8::String> name, v8::Local<v8::Va
lue> value, const v8::PropertyCallbackInfo<void>& info) | 41 static void domExceptionStackSetter(v8::Local<v8::String> name, v8::Local<v8::Va
lue> value, const v8::PropertyCallbackInfo<void>& info) |
| 42 { | 42 { |
| 43 ASSERT(info.Data()->IsObject()); | 43 ASSERT(info.Data()->IsObject()); |
| 44 info.Data()->ToObject()->Set(v8AtomicString(info.GetIsolate(), "stack"), val
ue); | 44 info.Data()->ToObject()->Set(v8AtomicString(info.GetIsolate(), "stack"), val
ue); |
| 45 } | 45 } |
| 46 | 46 |
| 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(v8::Isolate* isolate,
int ec, const String& sanitizedMessage, const String& unsanitizedMessage, const
v8::Handle<v8::Object>& creationContext) |
| 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(isolate, sanitizedMessage); | 57 return V8ThrowException::createTypeError(isolate, sanitizedMessage); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 ASSERT(exception->IsObject()); | 74 ASSERT(exception->IsObject()); |
| 75 exception->ToObject()->SetAccessor(v8AtomicString(isolate, "stack"), domExce
ptionStackGetter, domExceptionStackSetter, error); | 75 exception->ToObject()->SetAccessor(v8AtomicString(isolate, "stack"), domExce
ptionStackGetter, domExceptionStackSetter, error); |
| 76 V8HiddenValue::setHiddenValue(isolate, exception->ToObject(), V8HiddenValue:
:error(isolate), error); | 76 V8HiddenValue::setHiddenValue(isolate, exception->ToObject(), V8HiddenValue:
:error(isolate), error); |
| 77 | 77 |
| 78 return exception; | 78 return exception; |
| 79 } | 79 } |
| 80 | 80 |
| 81 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object>
& creationContext, v8::Isolate* isolate) | 81 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object>
& creationContext, v8::Isolate* isolate) |
| 82 { | 82 { |
| 83 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); | 83 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); |
| 84 v8::Handle<v8::Value> exception = createDOMException(ec, sanitizedMessage, u
nsanitizedMessage, creationContext, isolate); | 84 v8::Handle<v8::Value> exception = createDOMException(isolate, ec, sanitizedM
essage, unsanitizedMessage, creationContext); |
| 85 if (exception.IsEmpty()) | 85 if (exception.IsEmpty()) |
| 86 return v8Undefined(); | 86 return v8Undefined(); |
| 87 | 87 |
| 88 return V8ThrowException::throwException(exception, isolate); | 88 return V8ThrowException::throwException(exception, isolate); |
| 89 } | 89 } |
| 90 | 90 |
| 91 v8::Handle<v8::Value> V8ThrowException::createGeneralError(v8::Isolate* isolate,
const String& message) | 91 v8::Handle<v8::Value> V8ThrowException::createGeneralError(v8::Isolate* isolate,
const String& message) |
| 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(v8::Isolate* isolate, co
nst String& message) | 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(v8::Isolate* isolate, con
st String& message) |
| 108 { | 108 { |
| 109 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(isolate,
message); | 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(v8::Isolate* isolate, c
onst String& message) | 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 |
| (...skipping 26 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 |