| 1 | package Zonemaster::Exception v1.0.0; | ||
| 2 | |||
| 3 | use 5.14.2; | ||
| 4 | use Moose; | ||
| 5 | |||
| 6 | use overload '""' => \&string; | ||
| 7 | |||
| 8 | has 'message' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
| 9 | |||
| 10 | sub string { | ||
| 11 | my ( $self ) = @_; | ||
| 12 | |||
| 13 | return $self->message; | ||
| 14 | } | ||
| 15 | |||
| 16 | no Moose; | ||
| 17 | __PACKAGE__->meta->make_immutable; | ||
| 18 | |||
| 19 | 1; | ||
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | Zonemaster::Exception -- base class for Zonemaster exceptions | ||
| 24 | |||
| 25 | =head1 SYNOPSIS | ||
| 26 | |||
| 27 | die Zonemaster::Exception->new({ message => "This is an exception" }); | ||
| 28 | |||
| 29 | =head1 ATTRIBUTES | ||
| 30 | |||
| 31 | =over | ||
| 32 | |||
| 33 | =item message | ||
| 34 | |||
| 35 | A string attribute holding a message for possible human consumption. | ||
| 36 | |||
| 37 | =back | ||
| 38 | |||
| 39 | =head1 METHODS | ||
| 40 | |||
| 41 | =over | ||
| 42 | |||
| 43 | =item string() | ||
| 44 | |||
| 45 | Method that stringifies the object by returning the C<message> attribute. | ||
| 46 | Stringification is overloaded to this. | ||
| 47 | |||
| 48 | =back | ||
| 49 | |||
| 50 | =cut |