File indexing completed on 2024-04-28 15:22:57

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright 1999 Lars Knoll (knoll@kde.org)
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  * This file includes excerpts from the Document Object Model (DOM)
0022  * Level 1 Specification (Recommendation)
0023  * https://www.w3.org/TR/REC-DOM-Level-1/
0024  * Copyright © World Wide Web Consortium , (Massachusetts Institute of
0025  * Technology , Institut National de Recherche en Informatique et en
0026  * Automatique , Keio University ). All Rights Reserved.
0027  *
0028  */
0029 #ifndef _DOM_DOMException_h_
0030 #define _DOM_DOMException_h_
0031 
0032 #include <dom/dom_misc.h>
0033 #include <dom/dom_string.h>
0034 
0035 namespace DOM
0036 {
0037 
0038 /**
0039  * DOM operations only raise exceptions in &quot;exceptional&quot;
0040  * circumstances, i.e., when an operation is impossible to perform
0041  * (either for logical reasons, because data is lost, or because the
0042  * implementation has become unstable). In general, DOM methods return
0043  * specific error values in ordinary processing situation, such as
0044  * out-of-bound errors when using \c NodeList .
0045  *
0046  *  Implementations may raise other exceptions under other
0047  * circumstances. For example, implementations may raise an
0048  * implementation-dependent exception if a \c null
0049  * argument is passed.
0050  *
0051  *  Some languages and object systems do not support the concept of
0052  * exceptions. For such systems, error conditions may be indicated
0053  * using native error reporting mechanisms. For some bindings, for
0054  * example, methods may return error codes similar to those listed in
0055  * the corresponding method descriptions.
0056  *
0057  */
0058 class KHTML_EXPORT DOMException
0059 {
0060 public:
0061     DOMException(unsigned short _code)
0062     {
0063         code = _code;
0064     }
0065     DOMException(const DOMException &other)
0066     {
0067         code = other.code;
0068     }
0069 
0070     DOMException &operator = (const DOMException &other)
0071     {
0072         code = other.code;
0073         return *this;
0074     }
0075 
0076     virtual ~DOMException() {}
0077     /**
0078      * An integer indicating the type of error generated.
0079      *
0080      */
0081     enum ExceptionCode {
0082         INDEX_SIZE_ERR = 1,
0083         DOMSTRING_SIZE_ERR = 2,
0084         HIERARCHY_REQUEST_ERR = 3,
0085         WRONG_DOCUMENT_ERR = 4,
0086         INVALID_CHARACTER_ERR = 5,
0087         NO_DATA_ALLOWED_ERR = 6,
0088         NO_MODIFICATION_ALLOWED_ERR = 7,
0089         NOT_FOUND_ERR = 8,
0090         NOT_SUPPORTED_ERR = 9,
0091         INUSE_ATTRIBUTE_ERR = 10,
0092         INVALID_STATE_ERR = 11,
0093         SYNTAX_ERR = 12,
0094         INVALID_MODIFICATION_ERR = 13,
0095         NAMESPACE_ERR = 14,
0096         INVALID_ACCESS_ERR = 15,
0097         VALIDATION_ERR = 16,
0098         TYPE_MISMATCH_ERR = 17,
0099         SECURITY_ERR = 18,
0100         NETWORK_ERR  = 19, ///< @since 4.5.2
0101         ABORT_ERR    = 20, ///< @since 4.5.2
0102         URL_MISMATCH_ERR   = 21, ///< @since 4.5.2
0103         QUOTA_EXCEEDED_ERR = 22, ///< @since 4.5.2
0104         TIMEOUT_ERR        = 23, ///< @since 4.5.2
0105         NOT_READABLE_ERR   = 24, ///< @since 4.5.2
0106         DATA_CLONE_ERR     = 25, ///< @since 4.5.2
0107         ENCODING_ERR       = 26  ///< @since 4.5.2
0108     };
0109     unsigned short code;
0110 
0111     /// Returns the name of this error
0112     DOMString codeAsString() const;
0113 
0114     /// Returns the name of given error code
0115     static DOMString codeAsString(int code);
0116 
0117     /** @internal - checks to see whether internal code is a DOMException one */
0118     static bool isDOMExceptionCode(int exceptioncode);
0119 
0120 };
0121 
0122 } //namespace
0123 #endif