| 1 | package AWS::Signature::V4::Error; | ||||||||||
| 2 | 10 | ▶ | use v5.24; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 10 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use Exporter qw< import >; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 10 | ▶ | use Ouch (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 10 | our @EXPORT_OK = qw< fail shown >; | |||||||||
| 8 | |||||||||||
| 9 | # Errors are reported at the caller's line, as croak would do: the frames of | ||||||||||
| 10 | # this distribution are skipped when Ouch looks for the culprit. | ||||||||||
| 11 | 10 | $Carp::Internal{$_}++ for qw< | |||||||||
| 12 | AWS::Signature::V4 AWS::Signature::V4::Checksum | ||||||||||
| 13 | AWS::Signature::V4::Chunker AWS::Signature::V4::Credentials | ||||||||||
| 14 | AWS::Signature::V4::Error AWS::Signature::V4::X509 | ||||||||||
| 15 | >; | ||||||||||
| 16 | |||||||||||
| 17 | # 400 for what the caller provided, 500 for problems inside the module; | ||||||||||
| 18 | # everything is passed down to ouch(), the optional third argument included. | ||||||||||
| 19 | # No "goto": it would drop the "local" before ouch() gets to build the trace. | ||||||||||
| 20 | 241 | ▶ | sub fail { | ||||||||
|
Subroutine
fail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 241 | local $Carp::MaxArgNums = -1; # the trace must not hold secrets | |||||||||
| 22 | 241 | Ouch::ouch(@_); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | # caller input, made safe to put in a message: anything that is not printable | ||||||||||
| 26 | # ASCII is escaped, so that it cannot forge lines in a log | ||||||||||
| 27 | 70 | ▶ | sub shown { | ||||||||
|
Subroutine
shown: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 28 | 70 | my ($value) = @_; | |||||||||
| 29 | 70 | ▶ | return 'undef' unless defined $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 70 | return $value =~ s{([^\x20-\x7E])}{sprintf '\\x{%X}', ord $1}ger; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 10 | 1; | |||||||||