| 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 15 matching lines...) Expand all Loading... |
| 26 #define V8ThrowException_h | 26 #define V8ThrowException_h |
| 27 | 27 |
| 28 #include "core/CoreExport.h" | 28 #include "core/CoreExport.h" |
| 29 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
| 30 #include "wtf/Allocator.h" | 30 #include "wtf/Allocator.h" |
| 31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
| 32 #include <v8.h> | 32 #include <v8.h> |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class ScriptState; |
| 37 class SourceLocation; |
| 38 |
| 36 // Provides utility functions to create and/or throw a V8 exception. | 39 // Provides utility functions to create and/or throw a V8 exception. |
| 37 // Mostly a set of wrapper functions for v8::Exception class. | 40 // Mostly a set of wrapper functions for v8::Exception class. |
| 38 class CORE_EXPORT V8ThrowException { | 41 class CORE_EXPORT V8ThrowException { |
| 39 STATIC_ONLY(V8ThrowException); | 42 STATIC_ONLY(V8ThrowException); |
| 40 public: | 43 public: |
| 41 // Creates and returns an exception object, or returns an empty handle if | 44 // Creates and returns an exception object, or returns an empty handle if |
| 42 // failed. |unsanitizedMessage| should not be specified unless it's | 45 // failed. |unsanitizedMessage| should not be specified unless it's |
| 43 // SecurityError. | 46 // SecurityError. |
| 44 static v8::Local<v8::Value> createDOMException(v8::Isolate*, ExceptionCode,
const String& sanitizedMessage, const String& unsanitizedMessage = String()); | 47 static v8::Local<v8::Value> createDOMException(v8::Isolate*, ExceptionCode,
const String& sanitizedMessage, const String& unsanitizedMessage = String()); |
| 45 | 48 |
| 46 static void throwException(v8::Isolate* isolate, v8::Local<v8::Value> except
ion) | 49 static void throwException(v8::Isolate* isolate, v8::Local<v8::Value> except
ion) |
| 47 { | 50 { |
| 48 if (!isolate->IsExecutionTerminating()) | 51 if (!isolate->IsExecutionTerminating()) |
| 49 isolate->ThrowException(exception); | 52 isolate->ThrowException(exception); |
| 50 } | 53 } |
| 51 | 54 |
| 52 static v8::Local<v8::Value> createError(v8::Isolate*, const String& message)
; | 55 static v8::Local<v8::Value> createError(v8::Isolate*, const String& message)
; |
| 53 static v8::Local<v8::Value> createRangeError(v8::Isolate*, const String& mes
sage); | 56 static v8::Local<v8::Value> createRangeError(v8::Isolate*, const String& mes
sage); |
| 54 static v8::Local<v8::Value> createReferenceError(v8::Isolate*, const String&
message); | 57 static v8::Local<v8::Value> createReferenceError(v8::Isolate*, const String&
message); |
| 55 static v8::Local<v8::Value> createSyntaxError(v8::Isolate*, const String& me
ssage); | 58 static v8::Local<v8::Value> createSyntaxError(v8::Isolate*, const String& me
ssage); |
| 56 static v8::Local<v8::Value> createTypeError(v8::Isolate*, const String& mess
age); | 59 static v8::Local<v8::Value> createTypeError(v8::Isolate*, const String& mess
age); |
| 57 | 60 |
| 58 static void throwError(v8::Isolate*, const String& message); | 61 static void throwError(v8::Isolate*, const String& message); |
| 59 static void throwRangeError(v8::Isolate*, const String& message); | 62 static void throwRangeError(v8::Isolate*, const String& message); |
| 60 static void throwReferenceError(v8::Isolate*, const String& message); | 63 static void throwReferenceError(v8::Isolate*, const String& message); |
| 61 static void throwSyntaxError(v8::Isolate*, const String& message); | 64 static void throwSyntaxError(v8::Isolate*, const String& message); |
| 62 static void throwTypeError(v8::Isolate*, const String& message); | 65 static void throwTypeError(v8::Isolate*, const String& message); |
| 66 |
| 67 static void reportException(ScriptState*, v8::Local<v8::Value> exception, |
| 68 const String& eventMessage, v8::Local<v8::Function>); |
| 69 |
| 70 private: |
| 71 static void reportException(ScriptState*, v8::Local<v8::Value> exception, |
| 72 const String& eventMessage, |
| 73 std::unique_ptr<SourceLocation>, const v8::ScriptOriginOptions&); |
| 63 }; | 74 }; |
| 64 | 75 |
| 65 } // namespace blink | 76 } // namespace blink |
| 66 | 77 |
| 67 #endif // V8ThrowException_h | 78 #endif // V8ThrowException_h |
| OLD | NEW |