| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return exception; | 70 return exception; |
| 71 } | 71 } |
| 72 | 72 |
| 73 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, v8::Isolate* isolate) | 73 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String&
sanitizedMessage, const String& unsanitizedMessage, v8::Isolate* isolate) |
| 74 { | 74 { |
| 75 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); | 75 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty()); |
| 76 v8::Handle<v8::Value> exception = createDOMException(ec, sanitizedMessage, u
nsanitizedMessage, isolate); | 76 v8::Handle<v8::Value> exception = createDOMException(ec, sanitizedMessage, u
nsanitizedMessage, isolate); |
| 77 if (exception.IsEmpty()) | 77 if (exception.IsEmpty()) |
| 78 return v8Undefined(); | 78 return v8Undefined(); |
| 79 | 79 |
| 80 return V8ThrowException::throwError(exception); | 80 return V8ThrowException::throwError(exception, isolate); |
| 81 } | 81 } |
| 82 | 82 |
| 83 v8::Handle<v8::Value> V8ThrowException::createError(V8ErrorType type, const Stri
ng& message, v8::Isolate* isolate) | 83 v8::Handle<v8::Value> V8ThrowException::createError(V8ErrorType type, const Stri
ng& message, v8::Isolate* isolate) |
| 84 { | 84 { |
| 85 switch (type) { | 85 switch (type) { |
| 86 case v8RangeError: | 86 case v8RangeError: |
| 87 return v8::Exception::RangeError(v8String(message, isolate)); | 87 return v8::Exception::RangeError(v8String(message, isolate)); |
| 88 case v8ReferenceError: | 88 case v8ReferenceError: |
| 89 return v8::Exception::ReferenceError(v8String(message, isolate)); | 89 return v8::Exception::ReferenceError(v8String(message, isolate)); |
| 90 case v8SyntaxError: | 90 case v8SyntaxError: |
| 91 return v8::Exception::SyntaxError(v8String(message, isolate)); | 91 return v8::Exception::SyntaxError(v8String(message, isolate)); |
| 92 case v8TypeError: | 92 case v8TypeError: |
| 93 return v8::Exception::TypeError(v8String(message, isolate)); | 93 return v8::Exception::TypeError(v8String(message, isolate)); |
| 94 case v8GeneralError: | 94 case v8GeneralError: |
| 95 return v8::Exception::Error(v8String(message, isolate)); | 95 return v8::Exception::Error(v8String(message, isolate)); |
| 96 default: | 96 default: |
| 97 ASSERT_NOT_REACHED(); | 97 ASSERT_NOT_REACHED(); |
| 98 return v8Undefined(); | 98 return v8Undefined(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 v8::Handle<v8::Value> V8ThrowException::throwError(V8ErrorType type, const Strin
g& message, v8::Isolate* isolate) | 102 v8::Handle<v8::Value> V8ThrowException::throwError(V8ErrorType type, const Strin
g& message, v8::Isolate* isolate) |
| 103 { | 103 { |
| 104 v8::Handle<v8::Value> exception = V8ThrowException::createError(type, messag
e, isolate); | 104 v8::Handle<v8::Value> exception = V8ThrowException::createError(type, messag
e, isolate); |
| 105 if (exception.IsEmpty()) | 105 if (exception.IsEmpty()) |
| 106 return v8Undefined(); | 106 return v8Undefined(); |
| 107 return V8ThrowException::throwError(exception); | 107 return V8ThrowException::throwError(exception, isolate); |
| 108 } | 108 } |
| 109 | 109 |
| 110 v8::Handle<v8::Value> V8ThrowException::createTypeError(const String& message, v
8::Isolate* isolate) | 110 v8::Handle<v8::Value> V8ThrowException::createTypeError(const String& message, v
8::Isolate* isolate) |
| 111 { | 111 { |
| 112 return v8::Exception::TypeError(v8String(message.isNull() ? "Type error" : m
essage, isolate)); | 112 return v8::Exception::TypeError(v8String(message.isNull() ? "Type error" : m
essage, isolate)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 v8::Handle<v8::Value> V8ThrowException::throwTypeError(const String& message, v8
::Isolate* isolate) | 115 v8::Handle<v8::Value> V8ThrowException::throwTypeError(const String& message, v8
::Isolate* isolate) |
| 116 { | 116 { |
| 117 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(message,
isolate); | 117 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(message,
isolate); |
| 118 return V8ThrowException::throwError(exception); | 118 return V8ThrowException::throwError(exception, isolate); |
| 119 } | 119 } |
| 120 | 120 |
| 121 v8::Handle<v8::Value> V8ThrowException::throwNotEnoughArgumentsError(v8::Isolate
* isolate) | 121 v8::Handle<v8::Value> V8ThrowException::throwNotEnoughArgumentsError(v8::Isolate
* isolate) |
| 122 { | 122 { |
| 123 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError("Not eno
ugh arguments", isolate); | 123 v8::Handle<v8::Value> exception = V8ThrowException::createTypeError("Not eno
ugh arguments", isolate); |
| 124 return V8ThrowException::throwError(exception); | 124 return V8ThrowException::throwError(exception, isolate); |
| 125 } | 125 } |
| 126 | 126 |
| 127 v8::Handle<v8::Value> V8ThrowException::throwError(v8::Handle<v8::Value> excepti
on) | 127 v8::Handle<v8::Value> V8ThrowException::throwError(v8::Handle<v8::Value> excepti
on, v8::Isolate* isolate) |
| 128 { | 128 { |
| 129 if (!v8::V8::IsExecutionTerminating()) | 129 if (!v8::V8::IsExecutionTerminating()) |
| 130 v8::ThrowException(exception); | 130 v8::ThrowException(exception); |
| 131 return v8::Undefined(); | 131 return v8::Undefined(isolate); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace WebCore | 134 } // namespace WebCore |
| OLD | NEW |