~ubuntu-branches/ubuntu/feisty/libapache2-mod-perl2/feisty-security

« back to all changes in this revision

Viewing changes to xs/APR/Error/Error_pm

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2004-08-19 06:23:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040819062348-jxl4koqbtvgm8v2t
Tags: 1.99.14-4
Remove the LFS CFLAGS, and build-dep against apache2-*-dev (>= 2.0.50-10)
as we're backing out of the apache2/apr ABI transition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require Carp;
 
2
require Carp::Heavy;
 
3
 
 
4
use APR::Util ();
 
5
 
 
6
use overload
 
7
    nomethod => \&fatal,
 
8
    'bool'   => \&str,
 
9
    '=='     => \&num,
 
10
    '0+'     => \&num,
 
11
    '""'     => \&str;
 
12
 
 
13
sub fatal {  die __PACKAGE__ . ": Can't handle '$_[3]'" }
 
14
 
 
15
# normally the object is created on the C side, but if you want to
 
16
# create one from Perl, you can. just pass a hash with args:
 
17
# rc, file, line, func
 
18
sub new {
 
19
    my $class = shift;
 
20
    my %args = @_;
 
21
    bless \%args, $class;
 
22
}
 
23
 
 
24
sub str {
 
25
    sprintf "%s: %s at %s line %d", $_[0]->{func},
 
26
        APR::Error::strerror($_[0]->{rc}),
 
27
        $_[0]->{file}, $_[0]->{line};
 
28
}
 
29
 
 
30
sub num { $_[0]->{rc} }
 
31
 
 
32
# skip the wrappers from this package from the long callers trace
 
33
$Carp::CarpInternal{+__PACKAGE__}++;
 
34
 
 
35
# XXX: Carp::(confess|cluck) see no calls stack when Perl_croak is
 
36
# called with Nullch (which is the way execption objects are
 
37
# returned), so we fixup it here (doesn't quite work for croak
 
38
# caller).
 
39
sub cluck {
 
40
    if (ref $_[0] eq __PACKAGE__) {
 
41
        Carp::cluck("$_[0]->{func}: " .
 
42
                    APR::Error::strerror($_[0]->{rc}));
 
43
    }
 
44
    else {
 
45
        &Carp::cluck;
 
46
    }
 
47
}
 
48
 
 
49
sub confess {
 
50
    if (ref $_[0] eq __PACKAGE__) {
 
51
        Carp::confess("$_[0]->{func}: " .
 
52
                    APR::Error::strerror($_[0]->{rc}));
 
53
    }
 
54
    else {
 
55
        &Carp::confess;
 
56
    }
 
57
}
 
58
 
 
59
1;
 
60
__END__