Diff
Modified: trunk/Source/WebCore/ChangeLog (203333 => 203334)
--- trunk/Source/WebCore/ChangeLog 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/ChangeLog 2016-07-17 19:12:49 UTC (rev 203334)
@@ -1,5 +1,32 @@
2016-07-17 Brady Eidson <[email protected]>
+ Exceptions logged to the JS console should use toString().
+ https://bugs.webkit.org/show_bug.cgi?id=159855
+
+ Reviewed by Darin Adler.
+
+ No new tests (No change in behavior).
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::reportException):
+
+ * dom/DOMCoreException.h:
+ (WebCore::DOMCoreException::DOMCoreException):
+
+ * dom/ExceptionBase.cpp:
+ (WebCore::ExceptionBase::ExceptionBase):
+ (WebCore::ExceptionBase::toString):
+ (WebCore::ExceptionBase::consoleErrorMessage): Deleted.
+ * dom/ExceptionBase.h:
+ (WebCore::ExceptionBase::description): Deleted.
+
+ * svg/SVGException.h:
+
+ * xml/XPathException.h:
+ (WebCore::XPathException::XPathException):
+
+2016-07-17 Brady Eidson <[email protected]>
+
Update DOMCoreException to use the description in toString().
https://bugs.webkit.org/show_bug.cgi?id=159857
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (203333 => 203334)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2016-07-17 19:12:49 UTC (rev 203334)
@@ -200,7 +200,7 @@
String errorMessage;
JSValue exceptionValue = exception->value();
if (ExceptionBase* exceptionBase = toExceptionBase(exceptionValue))
- errorMessage = exceptionBase->consoleErrorMessage();
+ errorMessage = exceptionBase->toString();
else {
// FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate _javascript_ handling exceptions
// If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
Modified: trunk/Source/WebCore/dom/DOMCoreException.h (203333 => 203334)
--- trunk/Source/WebCore/dom/DOMCoreException.h 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/dom/DOMCoreException.h 2016-07-17 19:12:49 UTC (rev 203334)
@@ -44,7 +44,7 @@
protected:
explicit DOMCoreException(const ExceptionCodeDescription& description)
- : ExceptionBase(description, ExceptionBase::MessageSource::UseDescription)
+ : ExceptionBase(description)
{
}
};
Modified: trunk/Source/WebCore/dom/ExceptionBase.cpp (203333 => 203334)
--- trunk/Source/WebCore/dom/ExceptionBase.cpp 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/dom/ExceptionBase.cpp 2016-07-17 19:12:49 UTC (rev 203334)
@@ -33,45 +33,29 @@
namespace WebCore {
-ExceptionBase::ExceptionBase(const ExceptionCodeDescription& description, MessageSource messageSource)
+ExceptionBase::ExceptionBase(const ExceptionCodeDescription& description)
: m_code(description.code)
, m_name(description.name)
- , m_description(description.description)
+ , m_message(description.description)
, m_typeName(description.typeName)
- , m_messageSource(messageSource)
{
- if (messageSource == MessageSource::UseDescription) {
- m_message = m_description;
- return;
- }
-
- if (description.name)
- m_message = m_name + ": " + description.typeName + " Exception " + String::number(description.code);
- else
- m_message = makeString(description.typeName, " Exception ", String::number(description.code));
}
-String ExceptionBase::consoleErrorMessage() const
-{
- if (m_messageSource == MessageSource::UseDescription)
- return toString();
-
- return makeString(m_message, ": ", m_description);
-}
-
String ExceptionBase::toString() const
{
- if (m_messageSource != MessageSource::UseDescription)
- return makeString("Error: ", m_message);
+ if (!m_toString.isEmpty())
+ return m_toString;
String lastComponent;
- if (!m_description.isEmpty())
- lastComponent = makeString(": ", m_description);
+ if (!m_message.isEmpty())
+ lastComponent = makeString(": ", m_message);
if (m_name.isEmpty())
- return makeString(m_typeName, " Exception", m_code ? makeString(" ", String::number(m_code)) : "", lastComponent);
+ m_toString = makeString(m_typeName, " Exception", m_code ? makeString(" ", String::number(m_code)) : "", lastComponent);
+ else
+ m_toString = makeString(m_name, " (", m_typeName, " Exception", m_code ? makeString(" ", String::number(m_code)) : "", ")", lastComponent);
- return makeString(m_name, " (", m_typeName, " Exception", m_code ? makeString(" ", String::number(m_code)) : "", ")", lastComponent);
+ return m_toString;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/ExceptionBase.h (203333 => 203334)
--- trunk/Source/WebCore/dom/ExceptionBase.h 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/dom/ExceptionBase.h 2016-07-17 19:12:49 UTC (rev 203334)
@@ -42,28 +42,18 @@
unsigned short code() const { return m_code; }
String name() const { return m_name; }
String message() const { return m_message; }
- String description() const { return m_description; }
String toString() const;
- // FIXME: consoleErrorMessage is needed temporarily while bug 159822 is in progress.
- // Once 159822 is complete, consoleErrorMessage can be dropped and its callers will use toString instead.
- String consoleErrorMessage() const;
-
protected:
- enum class MessageSource {
- ConstructMessage,
- UseDescription,
- };
- explicit ExceptionBase(const ExceptionCodeDescription&, MessageSource = MessageSource::ConstructMessage);
+ explicit ExceptionBase(const ExceptionCodeDescription&);
private:
unsigned short m_code;
String m_name;
String m_message;
- String m_description;
String m_typeName;
- MessageSource m_messageSource;
+ mutable String m_toString;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGException.h (203333 => 203334)
--- trunk/Source/WebCore/svg/SVGException.h 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/svg/SVGException.h 2016-07-17 19:12:49 UTC (rev 203334)
@@ -45,7 +45,7 @@
private:
SVGException(const ExceptionCodeDescription& description)
- : ExceptionBase(description, ExceptionBase::MessageSource::UseDescription)
+ : ExceptionBase(description)
{
}
};
Modified: trunk/Source/WebCore/xml/XPathException.h (203333 => 203334)
--- trunk/Source/WebCore/xml/XPathException.h 2016-07-17 16:47:55 UTC (rev 203333)
+++ trunk/Source/WebCore/xml/XPathException.h 2016-07-17 19:12:49 UTC (rev 203334)
@@ -52,7 +52,7 @@
private:
explicit XPathException(const ExceptionCodeDescription& description)
- : ExceptionBase(description, ExceptionBase::MessageSource::UseDescription)
+ : ExceptionBase(description)
{
}
};