Error.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« Profile.pm ↑ Summary DB.pm »
1 ############################################################################
2 #
3 # Win32::ASP::Error - an abstract parent class for supporting exceptions
4 # in the Win32-ASP-DB system
5 #
6 # Author: Toby Everett
7 # Revision: 0.02
8 # Last Change:
9 ############################################################################
10 # Copyright 1999, 2000 Toby Everett. All rights reserved.
11 #
12 # This file is distributed under the Artistic License. See
13 # http://www.ActiveState.com/corporate/artistic_license.htm or
14 # the license that comes with your perl distribution.
15 #
16 # For comments, questions, bugs or general interest, feel free to
17 # contact Toby Everett at teverett@alascom.att.com
18 ############################################################################
19
20 0 ▶use Error::Unhandled;
Subroutine BEGIN: called CC=1 SCAR=2.6
21 use Class::SelfMethods;
22
23 use strict;
24
25 =head1 NAME
26
27 Win32::ASP::Error - an abstract parent class for implementing exceptions in Win32::ASP::DB
28
29 =head1 SYNOPSIS
30
31 use Win32::ASP::Error;
32
33 package Win32::ASP::Error::DBRecord;
34 @Win32::ASP::Error::DBRecord::ISA = qw/Win32::ASP::Error/;
35
36 package Win32::ASP::Error::DBRecord::no_permission;
37 @Win32::ASP::Error::DBRecord::no_permission::ISA = qw/Win32::ASP::Error::DBRecord/;
38
39 #Parameters: action, identifier
40
41 sub _as_html {
42 my $self = shift;
43
44 my $action = $self->action;
45 my $identifier = $self->identifier;
46 return <<ENDHTML;
47 You are not allowed to $action $identifier.<P>
48 ENDHTML
49 }
50
51 throw Win32::ASP::Error::DBRecord::no_permission (action => 'view', identifier => $identifier);
52
53 =head1 DESCRIPTION
54
55 =head2 Overview
56
57 C<Win32::ASP::Error> is the abstract parent class used for implementing exceptions in the
58 Win32::ASP::DB system. It inherits from C<Error::Unhandled>, which allows exceptions to handle
59 themselves if the calling program leaves the exception unhandled, and C<Class::SelfMethods>, which
60 allows instances to override methods and provides for method/attribute calling equivalence.
61
62 =head2 Utilization
63
64 In general, subclasses of C<Win32::ASP::Error> implement the C<as_html> method (properly
65 implemented as C<_as_html> so that instances can override it if necessary - see the
66 C<Class::SelfMethods> documentation for more explanation). This method should return properly
67 formatted HTML that describes the condition that led to the exception and, if applicable, provides
68 instruction to the user about how to rectify the problem.
69
70 The return value from the C<title> method is used for the <TITLE> block in the returned web page.
71
72 =cut
73
74 package Win32::ASP::Error;
75 @Win32::ASP::Error::ISA = qw/Error::Unhandled Class::SelfMethods/;
76
77 sub _unhandled {
78 my $self = shift;
79
80 $main::Response->Clear;
81 my $title = $self->title;
82 my $mesg = $self->as_html;
83 $main::Response->Write(<<ENDHTML);
84 <html>
85
86 <head>
87 <title>Error: $title</title>
88
89 </head>
90
91 <body bgcolor="#FFFFE1" text="#000000" link="#0000FF" vlink="#800080" alink="#4000C0">
92 $mesg
93 </body>
94 </html>
95 ENDHTML
96
97 $main::Response->Flush;
98 $main::Response->End;
99 die;
100 }
101
102 sub _title {
103 my $self = shift;
104
105 return "";
106 }
107
108 1;
109
« Profile.pm ↑ Summary DB.pm »