| 1 | package Opsview::REST::Exception; | ||||||||||
| 2 | { | ||||||||||
| 3 | 9 | $Opsview::REST::Exception::VERSION = '0.013'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | use overload | ||||||||||
| 9 | 9 | ▶ | '""' => sub { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.7
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||
| 10 | 0 | my $error = join (' ', $_[0]->status, $_[0]->reason); | |||||||||
| 11 | 0 | ▶ | my $msg = $_[0]->message; chomp $msg if $msg; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | ▶ | my $dtl = $_[0]->detail; chomp $dtl if $dtl; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | $error = join ': ', $error, $msg if ($msg); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 0 | ▶ | $error = join '; ', $error, $dtl if ($dtl); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | return "$error\n"; | |||||||||
| 18 | }, | ||||||||||
| 19 | 9 | fallback => 1; | |||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | 9 | has [qw/status reason/] => ( | |||||||||
| 23 | is => 'ro', | ||||||||||
| 24 | required => 1, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 9 | has [qw/message detail/] => ( | |||||||||
| 28 | is => 'ro', | ||||||||||
| 29 | required => 0, | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | 9 | __PACKAGE__->meta->make_immutable; | |||||||||
| 33 | |||||||||||
| 34 | 9 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||