ASP4
view release on metacpan or search on metacpan
lib/ASP4/Error.pm view on Meta::CPAN
# Allow overrides:
%args
);
return bless \%info, $class;
}# end new()
sub domain { $_[0]->{domain} }
sub request_uri { $_[0]->{request_uri} }
sub file { $_[0]->{file} }
sub line { $_[0]->{line} }
sub message { $_[0]->{message} }
sub stacktrace { $_[0]->{stacktrace} }
sub code { $_[0]->{code} }
sub form_data { $_[0]->{form_data} }
sub session_data { $_[0]->{session_data} }
sub http_referer { $_[0]->{http_referer} }
sub user_agent { $_[0]->{user_agent} }
sub http_code { $_[0]->{http_code} }
sub remote_addr { $_[0]->{remote_addr} }
# Find the numbers within a given range, but not less than 1 and not greater than max.
sub _number_range
{
my ($s, $number, $max, $padding) = @_;
my $low = $number - $padding > 0 ? $number - $padding : 1;
my $high = $number + $padding <= $max ? $number + $padding : $max;
return ($low, $high);
}# end _number_range()
1;# return true:
=pod
=head1 NAME
ASP4::Error - Representation of a server-side error
=head1 SYNOPSIS
use ASP4::Error;
# Pass in the $@ value after something dies or confesses:
eval { die "Foo" };
if( $@ ) {
my $error = ASP4::Error->new( $@ )
}
# Pass in your own info:
unless( $something ) {
my $error = ASP4::Error->new(
message => "If can, can. If no can, no can!"
);
}
=head1 DESCRIPTION
ASP4 provides a simple means of dealing with errors. It emails them, by default,
to an email address you specify.
Sometimes that is not convenient. Maybe you want to do something special with
the error - like log it someplace special.
ASP4::Error is a simple representation of a server-side error.
=head1 PUBLIC READ-ONLY PROPERTIES
=head2 domain
C<<$Config->errors->domain>> or C<$ENV{HTTP_HOST}>
=head2 request_uri
C<$ENV{REQUEST_URI}>
=head2 file
The name of the file in which the error occurred. This is gleaned from C<$@> unless C<file> is
passed to the constructor.
=head2 line
The line number within the file that the error occurred. This is gleaned from C<$@> unless
C<line> is passed to the constructor.
=head2 code
A string. Includes the 5 lines of code before and after the line of code where the error occurred.
=head2 message
Defaults to the first part of C<$@> unless otherwise specified.
=head2 stacktrace
A string - defaults to the value of C<$@>.
=head2 form_data
JSON-encoded C<$Form> object.
=head2 session_data
JSON-encoded C<$Session> object.
=head2 http_referer
Default value is C<$ENV{HTTP_REFERER}>
=head2 user_agent
Default value is C<$ENV{HTTP_USER_AGENT}>
=head2 http_code
The current value of C<<$Response->Status>>
=head2 remote_addr
Default value is C<$ENV{REMOTE_ADDR}> -- the IP address of the remote client.
=head1 BUGS
It's possible that some bugs have found their way into this release.
Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.
=head1 HOMEPAGE
Please visit the ASP4 homepage at L<http://0x31337.org/code/> to see examples
of ASP4 in action.
=cut
( run in 1.286 second using v1.01-cache-2.11-cpan-39bf76dae61 )