/[suikacvs]/messaging/manakai/lib/Message/DOM/DOMError.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/DOMError.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Jun 21 11:59:36 2007 UTC (19 years, 1 month ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
++ manakai/lib/Message/DOM/ChangeLog	21 Jun 2007 11:56:16 -0000
2007-06-21  Wakaba  <wakaba@suika.fam.cx>

	* DOMLocator.pm: New module.

	* DOMError.pm: New module.

1 package Message::DOM::DOMError;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.5 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::Util::Error', 'Message::IF::DOMError';
5 require Message::Util::Error;
6
7 ## |DOMError| constants
8
9 ## ErrorSeveriry
10 sub SEVERITY_WARNING () { 1 }
11 sub SEVERITY_ERROR () { 2 }
12 sub SEVERITY_FATAL_ERROR () { 3 }
13
14 sub ___error_def () {+{
15 }} # ___error_def
16
17 # sub _FORMATTER_PACKAGE_ { $_[0]->{-def}->{manakai_formatter_package} }
18
19 ## |DOMError| attributes
20
21 sub location ($) {
22 require Message::DOM::DOMLocator;
23 return bless $_[0]->{location} ||= {}, 'Message::DOM::DOMLocator';
24 } # location
25
26 ## NOTE: In manakai, this attribute returns an error message
27 ## string written in the |i-default| language. Note that
28 ## it is same as |text| attribute.
29 sub message ($) {
30 goto &{$_[0]->can ('text')};
31 } # message
32
33 sub related_data ($) {
34 return $_[0]->{related_data};
35 } # related_data
36
37 sub related_exception ($) {
38 return $_[0]->{related_exception};
39 } # related_exception
40
41 sub severity ($) {
42 return $_[0]->{-def}->{severity};
43 } # severity
44
45 ## type - defined in |Message::Util::Error|.
46
47 ## |DOMError| manakai's Perl Binding method
48
49 ## ISSUE: Document this in the spec.
50
51 use overload
52 '""' => 'stringify',
53 fallback => 1;
54
55 sub stringify ($) {
56 local $Error::Depth = $Error::Depth + 1;
57 my $r = '';
58
59 my $loc = $_[0]->location;
60 my $uri = $loc->uri;
61 $r .= " <$uri>" if defined $uri;
62
63 my $line = $loc->line_number;
64 $r .= " Line $line " if $line >= 0;
65
66 my $column = $loc->column_number;
67 $r .= " Column $column " if $column >= 0;
68
69 substr ($r, 0, 1) = '';
70 $r .= ': ' if length $r;
71
72 $r .= $_[0]->SUPER::stringify;
73 return $r;
74 } # stringify
75
76 ## ISSUE: Document that a |DOMErrorHandler| MUST be a CODE reference
77 ## in the Perl DOM Binding spec.
78
79 package Message::IF::DOMError;
80 push our @ISA, 'Message::Util::Error';
81
82 =head1 LICENSE
83
84 Copyright 2007 Wakaba <[email protected]>
85
86 This program is free software; you can redistribute it and/or
87 modify it under the same terms as Perl itself.
88
89 =cut
90
91 1;
92 ## $Date: 2007/06/20 13:41:16 $

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24