655
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
######################################################################
|
|
17 |
package XML::DOM::DOMException;
|
|
18 |
######################################################################
|
|
19 |
|
|
20 |
use Exporter;
|
|
21 |
|
|
22 |
use overload '""' => \&stringify;
|
|
23 |
use vars qw ( @ISA @EXPORT @ErrorNames );
|
|
24 |
|
|
25 |
BEGIN
|
|
26 |
{
|
|
27 |
@ISA = qw( Exporter );
|
|
28 |
@EXPORT = qw( INDEX_SIZE_ERR
|
|
29 |
DOMSTRING_SIZE_ERR
|
|
30 |
HIERARCHY_REQUEST_ERR
|
|
31 |
WRONG_DOCUMENT_ERR
|
|
32 |
INVALID_CHARACTER_ERR
|
|
33 |
NO_DATA_ALLOWED_ERR
|
|
34 |
NO_MODIFICATION_ALLOWED_ERR
|
|
35 |
NOT_FOUND_ERR
|
|
36 |
NOT_SUPPORTED_ERR
|
|
37 |
INUSE_ATTRIBUTE_ERR
|
|
38 |
);
|
|
39 |
}
|
|
40 |
|
|
41 |
sub UNKNOWN_ERR () {0;} # not in the DOM Spec!
|
|
42 |
sub INDEX_SIZE_ERR () {1;}
|
|
43 |
sub DOMSTRING_SIZE_ERR () {2;}
|
|
44 |
sub HIERARCHY_REQUEST_ERR () {3;}
|
|
45 |
sub WRONG_DOCUMENT_ERR () {4;}
|
|
46 |
sub INVALID_CHARACTER_ERR () {5;}
|
|
47 |
sub NO_DATA_ALLOWED_ERR () {6;}
|
|
48 |
sub NO_MODIFICATION_ALLOWED_ERR () {7;}
|
|
49 |
sub NOT_FOUND_ERR () {8;}
|
|
50 |
sub NOT_SUPPORTED_ERR () {9;}
|
|
51 |
sub INUSE_ATTRIBUTE_ERR () {10;}
|
|
52 |
|
|
53 |
@ErrorNames = (
|
|
54 |
"UNKNOWN_ERR",
|
|
55 |
"INDEX_SIZE_ERR",
|
|
56 |
"DOMSTRING_SIZE_ERR",
|
|
57 |
"HIERARCHY_REQUEST_ERR",
|
|
58 |
"WRONG_DOCUMENT_ERR",
|
|
59 |
"INVALID_CHARACTER_ERR",
|
|
60 |
"NO_DATA_ALLOWED_ERR",
|
|
61 |
"NO_MODIFICATION_ALLOWED_ERR",
|
|
62 |
"NOT_FOUND_ERR",
|
|
63 |
"NOT_SUPPORTED_ERR",
|
|
64 |
"INUSE_ATTRIBUTE_ERR"
|
|
65 |
);
|
|
66 |
sub new
|
|
67 |
{
|
|
68 |
my ($type, $code, $msg) = @_;
|
|
69 |
my $self = bless {Code => $code}, $type;
|
|
70 |
|
|
71 |
$self->{Message} = $msg if defined $msg;
|
|
72 |
|
|
73 |
# print "=> Exception: " . $self->stringify . "\n";
|
|
74 |
$self;
|
|
75 |
}
|
|
76 |
|
|
77 |
sub getCode
|
|
78 |
{
|
|
79 |
$_[0]->{Code};
|
|
80 |
}
|
|
81 |
|
|
82 |
#------------------------------------------------------------
|
|
83 |
# Extra method implementations
|
|
84 |
|
|
85 |
sub getName
|
|
86 |
{
|
|
87 |
$ErrorNames[$_[0]->{Code}];
|
|
88 |
}
|
|
89 |
|
|
90 |
sub getMessage
|
|
91 |
{
|
|
92 |
$_[0]->{Message};
|
|
93 |
}
|
|
94 |
|
|
95 |
sub stringify
|
|
96 |
{
|
|
97 |
my $self = shift;
|
|
98 |
|
|
99 |
"XML::DOM::DOMException(Code=" . $self->getCode . ", Name=" .
|
|
100 |
$self->getName . ", Message=" . $self->getMessage . ")";
|
|
101 |
}
|
|
102 |
|
|
103 |
1; # package return code
|