File: Error.pm

package info (click to toggle)
psp 0.5.5-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 4,820 kB
  • ctags: 2,333
  • sloc: perl: 21,074; ansic: 4,553; sh: 2,407; makefile: 461; php: 11; pascal: 6
file content (152 lines) | stat: -rw-r--r-- 3,304 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package PSP::Parser::Error;

# Copyright (c) 2000, FundsXpress Financial Network, Inc.
# This library is free software released under the GNU Lesser General
# Public License, Version 2.1.  Please read the important licensing and
# disclaimer information included below.

# $Id: Error.pm,v 1.1.1.2 2003/12/06 19:47:26 hartmans Exp $

use strict;

=head1 NAME

 PSP::Parser::Error - Tag extension for error handling.

=head1 SYNOPSIS

=head1 DESCRIPTION

=cut

use Error qw(:try);
use PSP::Parser;
use PSP::Utils;
use HTMLIO::Utils;

BEGIN {
  @PSP::Parser::Error::ISA = qw(PSP::Parser);
}

use vars qw(@handled @propagatable);
BEGIN {
  @handled = qw(errorreport handle throw);
};

=head1 TAG HANDLERS

=head2 begin_psperrorreport

 [private] instance
 () begin_psperrorreport (string $tag, \%attributes)

DESCRIPTION:

See PSP specification.

=cut

sub begin_psperrorreport {
  my ($this, $tag, $attr) = @_;

  $this->code('if ($fs->errors_p())');
  $this->begin_pspblock('fs->errors_p');

  $this->code('my %to_process; @to_process{ %{$fs->{errors}||{}} } = 1;');
  $this->code('for my $err (qw(field verify), sort keys %to_process)');
  $this->begin_pspblock('for(err)');

  $this->code('delete $to_process{$err} or next;');
  $this->code('my $error_obj = $fs->{errors}->{$err} or next;');
}

=head2 end_psperrorreport

 [private] instance
 () end_psperrorreport (string $tag)

DESCRIPTION:

See PSP specification.

=cut

sub end_psperrorreport {
  my ($this) = @_;

  $this->end_pspblock('while(error_obj)');
  $this->end_pspblock('if(fs->errors_p)');
}

=head2 begin_psphandle

 [private] instance
 () begin_psphandle (string $tag, \%attributes)

DESCRIPTION:

See PSP specification.

=cut

sub begin_psphandle {
  my ($this, $tag, $attr) = @_;

  my $type = $attr->{type} or throw
    Error::Simple("<$tag> requires a TYPE attribute.");

  $this->code('if (\$error_obj->isa("'.$type.'"))');
  $this->begin_pspblock('handle');
}

=head2 end_psphandle

 [private] instance
 () end_psphandle (string $tag)

DESCRIPTION:

See PSP specification.

=cut

sub end_psphandle {
  my ($this, $tag) = @_;
  $this->end_pspblock('handle');
}

1;
__END__

=head1 BUGS

No known bugs, but this does not mean no bugs exist.

=head1 SEE ALSO

L<HTML::Parser>, L<HTMLIO::Utils>

=head1 COPYRIGHT

 PSP - Perl Server Pages
 Copyright (c) 2000, FundsXpress Financial Network, Inc.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 BECAUSE THIS LIBRARY IS LICENSED FREE OF CHARGE, THIS LIBRARY IS
 BEING PROVIDED "AS IS WITH ALL FAULTS," WITHOUT ANY WARRANTIES
 OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT
 LIMITATION, ANY IMPLIED WARRANTIES OF TITLE, NONINFRINGEMENT,
 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, AND THE
 ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY,
 AND EFFORT IS WITH THE YOU.  See the GNU Lesser General Public
 License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

=cut