| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 virtual void throwTypeError(const String& message); | 81 virtual void throwTypeError(const String& message); |
| 82 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()); | 82 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()); |
| 83 | 83 |
| 84 // Please don't use these methods. Use ::throwDOMException and ::throwTypeEr
ror, and pass in a useful exception message. | 84 // Please don't use these methods. Use ::throwDOMException and ::throwTypeEr
ror, and pass in a useful exception message. |
| 85 virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& e
c) { throwDOMException(ec, String()); } | 85 virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& e
c) { throwDOMException(ec, String()); } |
| 86 virtual void throwUninformativeAndGenericTypeError() { throwTypeError(String
()); } | 86 virtual void throwUninformativeAndGenericTypeError() { throwTypeError(String
()); } |
| 87 | 87 |
| 88 bool hadException() const { return !m_exception.isEmpty() || m_code; } | 88 bool hadException() const { return !m_exception.isEmpty() || m_code; } |
| 89 void clearException(); | 89 void clearException(); |
| 90 | 90 |
| 91 ExceptionCode code() { return m_code; } | 91 ExceptionCode code() const { return m_code; } |
| 92 | 92 |
| 93 bool throwIfNeeded() | 93 bool throwIfNeeded() |
| 94 { | 94 { |
| 95 if (m_exception.isEmpty()) { | 95 if (m_exception.isEmpty()) { |
| 96 if (!m_code) | 96 if (!m_code) |
| 97 return false; | 97 return false; |
| 98 throwUninformativeAndGenericDOMException(m_code); | 98 throwUninformativeAndGenericDOMException(m_code); |
| 99 } | 99 } |
| 100 | 100 |
| 101 V8ThrowException::throwError(m_exception.newLocal(m_isolate), m_isolate)
; | 101 V8ThrowException::throwError(m_exception.newLocal(m_isolate), m_isolate)
; |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 Context context() { return m_context; } | 105 Context context() const { return m_context; } |
| 106 const char* propertyName() { return m_propertyName; } | 106 const char* propertyName() const { return m_propertyName; } |
| 107 const char* interfaceName() { return m_interfaceName; } | 107 const char* interfaceName() const { return m_interfaceName; } |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 ExceptionCode m_code; | 110 ExceptionCode m_code; |
| 111 Context m_context; | 111 Context m_context; |
| 112 const char* m_propertyName; | 112 const char* m_propertyName; |
| 113 const char* m_interfaceName; | 113 const char* m_interfaceName; |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 void setException(v8::Handle<v8::Value>); | 116 void setException(v8::Handle<v8::Value>); |
| 117 | 117 |
| 118 String addExceptionContext(const String&) const; |
| 119 |
| 118 ScopedPersistent<v8::Value> m_exception; | 120 ScopedPersistent<v8::Value> m_exception; |
| 119 v8::Handle<v8::Object> m_creationContext; | 121 v8::Handle<v8::Object> m_creationContext; |
| 120 v8::Isolate* m_isolate; | 122 v8::Isolate* m_isolate; |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 class TrackExceptionState : public ExceptionState { | 125 class TrackExceptionState : public ExceptionState { |
| 124 public: | 126 public: |
| 125 TrackExceptionState(): ExceptionState(v8::Handle<v8::Object>(), 0) { } | 127 TrackExceptionState(): ExceptionState(v8::Handle<v8::Object>(), 0) { } |
| 126 virtual void throwDOMException(const ExceptionCode&, const String& message)
OVERRIDE FINAL; | 128 virtual void throwDOMException(const ExceptionCode&, const String& message)
OVERRIDE FINAL; |
| 127 virtual void throwTypeError(const String& message = String()) OVERRIDE FINAL
; | 129 virtual void throwTypeError(const String& message = String()) OVERRIDE FINAL
; |
| 128 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()) OVERRIDE FINAL; | 130 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()) OVERRIDE FINAL; |
| 129 }; | 131 }; |
| 130 | 132 |
| 131 } // namespace WebCore | 133 } // namespace WebCore |
| 132 | 134 |
| 133 #endif // ExceptionState_h | 135 #endif // ExceptionState_h |
| OLD | NEW |