From: Tara L Andrews Date: Wed, 21 May 2014 13:23:48 +0000 (+0000) Subject: try to make sure our error messages are strings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11ccb53ac9f9670c908b00d34da7a5c28b14741f;p=scpubgit%2Fstemmatology.git try to make sure our error messages are strings --- diff --git a/base/lib/Text/Tradition/Error.pm b/base/lib/Text/Tradition/Error.pm index 0910175..818df2f 100644 --- a/base/lib/Text/Tradition/Error.pm +++ b/base/lib/Text/Tradition/Error.pm @@ -8,6 +8,17 @@ use overload '""' => \&_stringify, 'fallback' => 1; with qw/ Throwable::X StackTrace::Auto /; use Throwable::X -all; +around 'throw' => sub { + my $orig = shift; + my $self = shift; + my %args = @_; + my $msg = exists $args{message} ? $args{message} : undef; + if( $msg && UNIVERSAL::can( $msg, 'message' ) ) { + $args{message} = $msg->message; + } + $self->$orig( %args ); +}; + sub _stringify { my $self = shift; return "Error: " . $self->ident . " // " . $self->message