| 1 | package JSON::Pointer::Exception; | ||
| 2 | |||
| 3 | 17 | ▶ | use 5.008_001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 17 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 17 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 17 | ▶ | use overload ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 17 | q|""| => "to_string" | |
| 8 | 17 | ); | |
| 9 | |||
| 10 | 17 | ▶ | use Carp (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 17 | ▶ | use Exporter qw(import); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 17 | our $VERSION = '0.07'; | |
| 14 | 17 | our @EXPORT_OK = qw( | |
| 15 | ERROR_INVALID_POINTER_SYNTAX | ||
| 16 | ERROR_POINTER_REFERENCES_NON_EXISTENT_VALUE | ||
| 17 | ); | ||
| 18 | |||
| 19 | 17 | our %EXPORT_TAGS = ( | |
| 20 | all => [ @EXPORT_OK ], | ||
| 21 | ); | ||
| 22 | |||
| 23 | 22 | ▶ | sub ERROR_INVALID_POINTER_SYNTAX { 1; } |
|
Subroutine
ERROR_INVALID_POINTER_SYNTAX: called CC=1 SCAR=0.0
Pod
documented
| |||
| 24 | 77 | ▶ | sub ERROR_POINTER_REFERENCES_NON_EXISTENT_VALUE { 2; } |
|
Subroutine
ERROR_POINTER_REFERENCES_NON_EXISTENT_VALUE: called CC=1 SCAR=0.0
Pod
documented
| |||
| 25 | |||
| 26 | 17 | our %MESSAGE_BUNDLES = ( | |
| 27 | ERROR_INVALID_POINTER_SYNTAX() | ||
| 28 | => "Invalid pointer syntax (pointer: %s)", | ||
| 29 | ERROR_POINTER_REFERENCES_NON_EXISTENT_VALUE() | ||
| 30 | => "A pointer that references a non-existent value (pointer: %s)", | ||
| 31 | ); | ||
| 32 | |||
| 33 | 14 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 34 | 14 | my ($class, %opts) = @_; | |
| 35 | 14 | $opts{context}->last_error($opts{code}); | |
| 36 | bless { | ||
| 37 | code => $opts{code}, | ||
| 38 | context => $opts{context}, | ||
| 39 | 14 | } => $class | |
| 40 | } | ||
| 41 | |||
| 42 | 14 | ▶ | sub throw { |
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||
| 43 | 14 | Carp::croak(shift->new(@_)); | |
| 44 | } | ||
| 45 | |||
| 46 | 6 | ▶ | sub code { |
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||
| 47 | 6 | shift->{code}; | |
| 48 | } | ||
| 49 | |||
| 50 | 10 | ▶ | sub context { |
|
Subroutine
context: called CC=1 SCAR=0.0
Pod
documented
| |||
| 51 | 10 | shift->{context}; | |
| 52 | } | ||
| 53 | |||
| 54 | 14 | ▶ | sub to_string { |
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
documented
| |||
| 55 | 14 | my $self = shift; | |
| 56 | 14 | sprintf($MESSAGE_BUNDLES{$self->{code}}, $self->{context}{pointer}); | |
| 57 | } | ||
| 58 | |||
| 59 | 17 | 1; | |
| 60 | __END__ | ||