Add code to DOMException to ensure it cannot be instantiated directly,

since the API documentation will state specifically that the specializations
must be used by the DOM implementations.
This commit is contained in:
Fred Drake 2000-12-13 16:35:53 +00:00
parent 64acf1db22
commit 5d1b5eaf55
1 changed files with 8 additions and 1 deletions

View File

@ -38,6 +38,7 @@ class Node:
DOCUMENT_FRAGMENT_NODE = 11 DOCUMENT_FRAGMENT_NODE = 11
NOTATION_NODE = 12 NOTATION_NODE = 12
#ExceptionCode #ExceptionCode
INDEX_SIZE_ERR = 1 INDEX_SIZE_ERR = 1
DOMSTRING_SIZE_ERR = 2 DOMSTRING_SIZE_ERR = 2
@ -55,11 +56,17 @@ INVALID_MODIFICATION_ERR = 13
NAMESPACE_ERR = 14 NAMESPACE_ERR = 14
INVALID_ACCESS_ERR = 15 INVALID_ACCESS_ERR = 15
class DOMException(Exception): class DOMException(Exception):
"""Abstract base class for DOM exceptions. """Abstract base class for DOM exceptions.
Exceptions with specific codes are specializations of this class.""" Exceptions with specific codes are specializations of this class."""
pass def __init__(self, *args, **kw):
if self.__class__ is DOMException:
raise RuntimeError(
"DOMException should not be instaniated directly")
apply(Exception.__init__, args, kw)
class IndexSizeErr(DOMException): class IndexSizeErr(DOMException):
code = INDEX_SIZE_ERR code = INDEX_SIZE_ERR