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