File Coverage

blib/lib/CSS/DOM/Exception.pm
Criterion Covered Total %
statement 11 13 84.6
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 17 20 85.0


line stmt bran cond sub pod time code
1             package CSS::DOM::Exception;
2              
3 25     25   118592 use CSS::DOM::Constants;
  25         76  
  25         1220  
4 25     25   177 use Exporter 5.57 'import';
  25         488  
  25         4262  
5              
6             our $VERSION = '0.15';
7              
8             *EXPORT_OK = $CSS::DOM::Constants::EXPORT_TAGS{exception};
9             our %EXPORT_TAGS = (all => [@EXPORT_OK]);
10              
11              
12             use overload
13             fallback => 1,
14 109     109   15649 '0+' => sub { $_[0][0] },
15 0     0   0 '""' => sub { $_[0][1] =~ /^(.*?)\n?\z/s; "$1\n" },
  0         0  
16 25     25   19364 ;
  25         15242  
  25         313  
17              
18             sub new {
19 115     115 1 1400 bless [@_[1,2]], $_[0];
20             }
21              
22             'true'
23             __END__
24              
25             =head1 NAME
26              
27             CSS::DOM::Exception - The Exception interface for CSS::DOM
28              
29             =head1 SYNOPSIS
30              
31             use CSS::DOM::Exception 'SYNTAX_ERR';
32              
33             eval {
34             die new CSS::DOM::Exception
35             SYNTAX_ERR,
36             '1 is not a valid property declaration'
37             };
38              
39             $@ == SYNTAX_ERR; # true
40              
41             print $@; # prints "1 is not a valid property declaration\n";
42              
43             =head1 DESCRIPTION
44              
45             This module implementations the W3C's DOMException
46             interface.
47             CSS::DOM::Exception objects
48             stringify to the message passed to the constructer and numify to the
49             error
50             number (see below, under L<'EXPORTS'>).
51              
52             =head1 METHODS
53              
54             =over 4
55              
56             =item new CSS::DOM::Exception $type, $message
57              
58             This class method creates a new exception object. C<$type> is expected to
59             be an integer (you can use the constants listed under L<'EXPORTS'>).
60             C<$message> is the error message.
61              
62             =cut
63              
64             sub new {
65             bless [@_[1,2]], shift;
66             }
67              
68              
69             =back
70              
71             =head1 EXPORTS
72              
73             The following constants are optionally exported. The descriptions are
74             copied from the DOM spec.
75              
76             =over 4
77              
78             =item INDEX_SIZE_ERR (1)
79              
80             If index or size is negative, or greater than the allowed value
81              
82             =item DOMSTRING_SIZE_ERR (2)
83              
84             If the specified range of text does not fit into a DOMString
85              
86             =item HIERARCHY_REQUEST_ERR (3)
87              
88             If any node is inserted somewhere it doesn't belong
89              
90             =item WRONG_DOCUMENT_ERR (4)
91              
92             If a node is used in a different document than the one that created it (that doesn't support it)
93              
94             =item INVALID_CHARACTER_ERR (5)
95              
96             If an invalid character is specified, such as in a name.
97              
98             =item NO_DATA_ALLOWED_ERR (6)
99              
100             If data is specified for a node which does not support data
101              
102             =item NO_MODIFICATION_ALLOWED_ERR (7)
103              
104             If an attempt is made to modify an object where modifications are not allowed
105              
106             =item NOT_FOUND_ERR (8)
107              
108             If an attempt was made to reference a node in a context where it does not exist
109              
110             =item NOT_SUPPORTED_ERR (9)
111              
112             If the implementation does not support the type of object requested
113              
114             =item INUSE_ATTRIBUTE_ERR (10)
115              
116             If an attempt is made to add an attribute that is already inuse elsewhere
117              
118             =item INVALID_STATE_ERR (11)
119              
120             If an attempt is made to use an object that is not, or is no longer,
121             usable
122              
123             =item SYNTAX_ERR (12)
124              
125             If an invalid or illegal string is specified
126              
127             =item INVALID_MODIFICATION_ERR (13)
128              
129             If an attempt is made to modify the type of the underlying object
130              
131             =item NAMESPACE_ERR (14)
132              
133             If an attempt is made to create or change an object in a way which is
134             incorrect with
135             regard to namespaces
136              
137             =item INVALID_ACCESS_ERR (15)
138              
139             If a parameter or an operation is not supported by the underlying object
140              
141             =begin comment
142              
143             =item UNSPECIFIED_EVENT_TYPE_ERR (0)
144              
145             If the Event's type was not specified by initializing the event before the
146             method was called. Specification of the Event's type as null or an empty
147             string will also trigger this exception.
148              
149             =end comment
150              
151             =back
152              
153             =head1 SEE ALSO
154              
155             L<CSS::DOM>, L<HTML::DOM::Exception>