OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 m_name = name; | 93 m_name = name; |
94 m_message = message; | 94 m_message = message; |
95 ScriptWrappable::init(this); | 95 ScriptWrappable::init(this); |
96 } | 96 } |
97 | 97 |
98 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& me
ssage) | 98 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& me
ssage) |
99 { | 99 { |
100 const CoreException* entry = getErrorEntry(ec); | 100 const CoreException* entry = getErrorEntry(ec); |
101 ASSERT(entry); | 101 ASSERT(entry); |
102 return adoptRef(new DOMException(entry->code, | 102 return adoptRef(new DOMException(entry->code, |
103 ASCIILiteral(entry->name ? entry->name : "Error"), | 103 entry->name ? entry->name : "Error", |
104 message.isNull() ? String(ASCIILiteral(entry->message)) : message)); | 104 message.isNull() ? String(entry->message) : message)); |
105 } | 105 } |
106 | 106 |
107 String DOMException::toString() const | 107 String DOMException::toString() const |
108 { | 108 { |
109 return name() + ": " + message(); | 109 return name() + ": " + message(); |
110 } | 110 } |
111 | 111 |
112 String DOMException::getErrorName(ExceptionCode ec) | 112 String DOMException::getErrorName(ExceptionCode ec) |
113 { | 113 { |
114 const CoreException* entry = getErrorEntry(ec); | 114 const CoreException* entry = getErrorEntry(ec); |
115 ASSERT(entry); | 115 ASSERT(entry); |
116 if (!entry) | 116 if (!entry) |
117 return ASCIILiteral("UnknownError"); | 117 return "UnknownError"; |
118 | 118 |
119 return ASCIILiteral(entry->name); | 119 return entry->name; |
120 } | 120 } |
121 | 121 |
122 String DOMException::getErrorMessage(ExceptionCode ec) | 122 String DOMException::getErrorMessage(ExceptionCode ec) |
123 { | 123 { |
124 const CoreException* entry = getErrorEntry(ec); | 124 const CoreException* entry = getErrorEntry(ec); |
125 ASSERT(entry); | 125 ASSERT(entry); |
126 if (!entry) | 126 if (!entry) |
127 return ASCIILiteral("Unknown error."); | 127 return "Unknown error."; |
128 | 128 |
129 return ASCIILiteral(entry->message); | 129 return entry->message; |
130 } | 130 } |
131 | 131 |
132 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec) | 132 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec) |
133 { | 133 { |
134 const CoreException* entry = getErrorEntry(ec); | 134 const CoreException* entry = getErrorEntry(ec); |
135 ASSERT(entry); | 135 ASSERT(entry); |
136 | 136 |
137 return (entry && entry->code) ? entry->code : 0; | 137 return (entry && entry->code) ? entry->code : 0; |
138 } | 138 } |
139 | 139 |
140 } // namespace WebCore | 140 } // namespace WebCore |
OLD | NEW |