« StructuredParameters/Exception/InvalidArrayLength.pm
↑ Summary
StructuredParameters/Exception/InvalidArrayPointer.pm »
| 1 | package PAGI::StructuredParameters::Exception; | ||
| 2 | 5 | $PAGI::StructuredParameters::Exception::VERSION = '0.001001'; | |
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 5 | ▶ | use overload '""' => sub { my ($self) = @_; $self->message }, fallback => 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # Base class for the structured-parameter exceptions. All represent malformed or | ||
| 8 | # incomplete incoming data and so map to a 400 (Bad Request). | ||
| 9 | |||
| 10 | 1 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 11 | 1 | my ($class, %args) = @_; | |
| 12 | 1 | return bless { %args }, $class; | |
| 13 | } | ||
| 14 | |||
| 15 | 1 | ▶ | sub throw { |
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||
| 16 | 1 | my ($class, %args) = @_; | |
| 17 | 1 | die $class->new(%args); | |
| 18 | } | ||
| 19 | |||
| 20 | 1 | ▶ | sub status { 400 } |
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||
| 21 | |||
| 22 | 0 | ▶ | sub message { 'General error with structured parameters.' } |
|
Subroutine
message: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 23 | |||
| 24 | 5 | 1; | |
| 25 | |||
| 26 | =encoding utf8 | ||
| 27 | |||
| 28 | =head1 NAME | ||
| 29 | |||
| 30 | PAGI::StructuredParameters::Exception - Base class for structured-parameter errors | ||
| 31 | |||
| 32 | =head1 DESCRIPTION | ||
| 33 | |||
| 34 | Base class for the exceptions raised by L<PAGI::StructuredParameters>. Every | ||
| 35 | subclass represents malformed or incomplete incoming data and reports an HTTP | ||
| 36 | L</status> of 400 (Bad Request). Instances stringify to their L</message>. | ||
| 37 | |||
| 38 | =head1 METHODS | ||
| 39 | |||
| 40 | =head2 new | ||
| 41 | |||
| 42 | my $err = PAGI::StructuredParameters::Exception->new(%args); | ||
| 43 | |||
| 44 | =head2 throw | ||
| 45 | |||
| 46 | PAGI::StructuredParameters::Exception->throw(%args); | ||
| 47 | |||
| 48 | Constructs an instance and C<die>s with it. | ||
| 49 | |||
| 50 | =head2 status | ||
| 51 | |||
| 52 | Returns C<400>. | ||
| 53 | |||
| 54 | =head2 message | ||
| 55 | |||
| 56 | Returns the human-readable error message. Overridden by subclasses. | ||
| 57 | |||
| 58 | =head1 AUTHOR | ||
| 59 | |||
| 60 | John Napiorkowski C<< <jjnapiork@cpan.org> >> | ||
| 61 | |||
| 62 | =head1 COPYRIGHT & LICENSE | ||
| 63 | |||
| 64 | Copyright 2026, John Napiorkowski. This library is free software; you can | ||
| 65 | redistribute it and/or modify it under the same terms as Perl itself. | ||
| 66 | |||
| 67 | =cut | ||