File: Base.pm

package info (click to toggle)
libhttp-exception-perl 0.04007-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 300 kB
  • sloc: perl: 232; makefile: 2
file content (110 lines) | stat: -rw-r--r-- 3,145 bytes parent folder | download
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
package HTTP::Exception::Base;
$HTTP::Exception::Base::VERSION = '0.04007';
use strict;
use warnings;
use base 'Exception::Class::Base';

################################################################################
# roll our own new, because of message
# error, message and status_message are synonyms
sub new {
    my $proto = shift;
    my $class = ref $proto || $proto;
    my %params = @_;
    $params{status_message} = delete $params{message} if (exists $params{message});

    $class->SUPER::new(%params);
}

################################################################################
# used by Exception::Class for as_string
sub full_message { shift->status_message }

################################################################################
# TODO default-value/required fields, maybe moose? but maybe a moose is too heavy
# but on the other hand, handmade accessors suck
sub status_message  {
    $_[0]->{status_message}         =   $_[1] if (@_ > 1);
    return $_[0]->{status_message}  ||= $_[0]->_status_message;
}
*message    = \&status_message;
*error      = \&status_message;

################################################################################
# though Exception::Class::Base does have fields, the Fields-Accessor returns ()
# so no shift->SUPER::Fields is required
sub Fields { qw(status_message) }

1;


=head1 NAME

HTTP::Exception::Base - Base Class for exception classes created by HTTP::Exception

=head1 VERSION

version 0.04007

=head1 DESCRIPTION

This Class is a Base class for exception classes created by HTTP::Exception.
It inherits from L<Exception::Class::Base>. Please refer to the Documentation
of L<Exception::Class::Base> for methods and accessors a HTTP::Exception inherits.

You won't use this Class directly, so refer to L<HTTP::Exception/"ACCESSORS">
and L<HTTP::Exception/"FIELDS">. The methods and attributes this Class provides
over Exception::Class::Base are described there.

=head1 AUTHOR

Thomas Mueller, C<< <tmueller at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-http-exception at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTTP-Exception>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc HTTP::Exception::Base

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTTP-Exception>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/HTTP-Exception>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/HTTP-Exception>

=item * Search CPAN

L<https://metacpan.org/release/HTTP-Exception>

=back

=head1 LICENSE AND COPYRIGHT

Copyright 2010 Thomas Mueller.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut