summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ExceptionBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ExceptionBase.cpp')
-rw-r--r--Source/WebCore/dom/ExceptionBase.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/Source/WebCore/dom/ExceptionBase.cpp b/Source/WebCore/dom/ExceptionBase.cpp
index 2ea679b1e..b6a44d0e0 100644
--- a/Source/WebCore/dom/ExceptionBase.cpp
+++ b/Source/WebCore/dom/ExceptionBase.cpp
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -29,23 +29,41 @@
#include "config.h"
#include "ExceptionBase.h"
+#include "ExceptionCodeDescription.h"
namespace WebCore {
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)
+{
+}
+
+ExceptionBase::ExceptionBase(unsigned short code, const String& name, const String& message, const String& typeName)
+ : m_code(code)
+ , m_name(name)
+ , m_message(message)
+ , m_typeName(typeName)
{
- 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::toString() const
{
- return "Error: " + m_message;
+ if (!m_toString.isEmpty())
+ return m_toString;
+
+ String lastComponent;
+ if (!m_message.isEmpty())
+ lastComponent = makeString(": ", m_message);
+
+ if (m_name.isEmpty())
+ 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 m_toString;
}
} // namespace WebCore