1/* 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY GOOGLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "config.h" 30#include "DOMCoreException.h" 31 32namespace WebCore { 33 34static struct CoreException { 35 const char* const name; 36 const char* const description; 37} coreExceptions[] = { 38 { "IndexSizeError", "Index or size was negative, or greater than the allowed value." }, 39 { 0, 0 }, // DOMStringSizeError 40 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong." }, 41 { "WrongDocumentError", "A Node was used in a different document than the one that created it (that doesn't support it)." }, 42 { "InvalidCharacterError", "An invalid or illegal character was specified, such as in an XML name." }, 43 { 0, 0 }, // NoDataAllowedError 44 { "NoModificationAllowedError", "An attempt was made to modify an object where modifications are not allowed." }, 45 { "NotFoundError", "An attempt was made to reference a Node in a context where it does not exist." }, 46 { "NotSupportedError", "The implementation did not support the requested type of object or operation." }, 47 { "InUseAttributeError", "An attempt was made to add an attribute that is already in use elsewhere." }, 48 { "InvalidStateError", "An attempt was made to use an object that is not, or is no longer, usable." }, 49 { "SyntaxError", "An invalid or illegal string was specified." }, 50 { "InvalidModificationError", "An attempt was made to modify the type of the underlying object." }, 51 { "NamespaceError", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces." }, 52 { "InvalidAccessError", "A parameter or an operation was not supported by the underlying object." }, 53 { 0, 0 }, // ValidationError 54 { "TypeMismatchError", "The type of an object was incompatible with the expected type of the parameter associated to the object." }, 55 { "SecurityError", "An attempt was made to break through the security policy of the user agent." }, 56 // FIXME: Couldn't find a description in the HTML/DOM specifications for NETWORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, and QUOTA_EXCEEDED_ERR 57 { "NetworkError", "A network error occurred." }, 58 { "AbortError", "The user aborted a request." }, 59 { "URLMismatchError", "A worker global scope represented an absolute URL that is not equal to the resulting absolute URL." }, 60 { "QuotaExceededError", "An attempt was made to add something to storage that exceeded the quota." }, 61 { "TimeoutError", "A timeout occurred." }, 62 { "InvalidNodeTypeError", "The supplied node is invalid or has an invalid ancestor for this operation." }, 63 { "DataCloneError", "An object could not be cloned." } 64}; 65 66bool DOMCoreException::initializeDescription(ExceptionCode ec, ExceptionCodeDescription* description) 67{ 68 description->typeName = "DOM"; 69 description->code = ec; 70 description->type = DOMCoreExceptionType; 71 72 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); 73 size_t tableIndex = ec - INDEX_SIZE_ERR; 74 75 description->name = tableIndex < tableSize ? coreExceptions[tableIndex].name : 0; 76 description->description = tableIndex < tableSize ? coreExceptions[tableIndex].description : 0; 77 78 return true; 79} 80 81} // namespace WebCore 82