You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
637 B

package ksb::BuildException;
# A class to wrap 'exception' messages for the script, allowing them to be
# dispatch based on type and automatically stringified.
use 5.014; # Needed for state keyword
use strict;
use warnings;
use overload
'""' => \&to_string;
our $VERSION = '0.10';
sub new
{
my ($class, $type, $msg) = @_;
return bless({
'exception_type' => $type,
'message' => $msg,
}, $class);
}
sub to_string
{
my $exception = shift;
return $exception->{exception_type} . " Error: " . $exception->{message};
}
sub message
{
my $self = shift;
return $self->{message};
}
1;