| 1 | package OpenInteract::Error; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: Error.pm,v 1.6 2002/01/02 02:43:53 lachoy Exp $ | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $OpenInteract::Error::VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # Collection of error tracking variables -- look ma, no 'use vars'! | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | $OpenInteract::Error::user_msg = undef; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | $OpenInteract::Error::system_msg = undef; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $OpenInteract::Error::type = undef; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | $OpenInteract::Error::package = undef; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | $OpenInteract::Error::filename = undef; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $OpenInteract::Error::line = undef; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | $OpenInteract::Error::method = undef; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | $OpenInteract::Error::extra = (); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | $OpenInteract::Error::notes = undef; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $OpenInteract::Error::user_msg = undef; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | $OpenInteract::Error::system_msg = undef; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $OpenInteract::Error::type = undef; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $OpenInteract::Error::package = undef; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $OpenInteract::Error::filename = undef; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $OpenInteract::Error::line = undef; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $OpenInteract::Error::method = undef; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $OpenInteract::Error::extra = {}; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $OpenInteract::Error::notes = undef; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # Retrieve all the package variables in a hashref | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return { user_msg => $OpenInteract::Error::user_msg, | |||||||||||||||||||||||||||||||||||||||||
| 39 | system_msg => $OpenInteract::Error::system_msg, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | type => $OpenInteract::Error::type, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | package => $OpenInteract::Error::package, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | filename => $OpenInteract::Error::filename, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | line => $OpenInteract::Error::line, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | method => $OpenInteract::Error::method, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | extra => $OpenInteract::Error::extra, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | notes => $OpenInteract::Error::notes }; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # Set all package variables | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=5 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ( $class, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # First clean everything up so there's nothing | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # hanging around from a previous error | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | OpenInteract::Error->clear; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # Then set everything passed in | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | foreach my $key ( keys %{ $p } ) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | warn "OpenInteractI::Error::set >> Setting error $key to $p->{ $key }\n" if ( DEBUG ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ${ 'OpenInteract::Error::' . $key } = $p->{ $key }; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | # Set the caller information if the user didn't pass | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # anything in | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | unless ( $p->{package} and $p->{filename} and $p->{line} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$p->{"package"} and $p->{"filename"} and $p->{"line"}
$p->{"package"} and $p->{"filename"}
MC/DC0%0/3
$p->{"package"} and $p->{"filename"} and $p->{"line"}
$p->{"package"}
$p->{"filename"}
$p->{"line"}
Truth table0%0/4
A and B and C
A= $p->{"package"}B= $p->{"filename"}C= $p->{"line"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ( $OpenInteract::Error::package, | |||||||||||||||||||||||||||||||||||||||||
| 73 | $OpenInteract::Error::filename, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | $OpenInteract::Error::line ) = caller; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return OpenInteract::Error->get; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | # Class method -- really we just collect the caller info and | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # send it over to the error object... | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub throw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my ( $class, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $R = OpenInteract::Request->instance; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | unless ( $p->{package} and $p->{filename} and $p->{line} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$p->{"package"} and $p->{"filename"} and $p->{"line"}
$p->{"package"} and $p->{"filename"}
MC/DC0%0/3
$p->{"package"} and $p->{"filename"} and $p->{"line"}
$p->{"package"}
$p->{"filename"}
$p->{"line"}
Truth table0%0/4
A and B and C
A= $p->{"package"}B= $p->{"filename"}C= $p->{"line"}
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ( $cpkg, $cfile, $cline ) = caller; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $p->{package} = $cpkg; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $p->{filename} = $cfile; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $p->{line} = $cline; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | my $error_obj_class = $R->CONFIG->{error}{error_object_class} || | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $R->CONFIG->{error_object_class}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$R->CONFIG->{'error'}{'error_object_class'} || $R->CONFIG->{'error_object_class'}
MC/DC0%0/2
$R->CONFIG->{'error'}{'error_object_class'} || $R->CONFIG->{'error_object_class'}
$R->CONFIG->{'error'}{'error_object_class'}
$R->CONFIG->{'error_object_class'}
Truth table0%0/3
A || B
A= $R->CONFIG->{'error'}{'error_object_class'}B= $R->CONFIG->{'error_object_class'}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return $error_obj_class->throw( $p ); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||||||||||||||||||||||||