THRIFT-3549 Exceptions are not properly stringified in Perl library
Patch: David Morel
diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm
index 5cabd80..bd7b65a 100644
--- a/lib/perl/lib/Thrift.pm
+++ b/lib/perl/lib/Thrift.pm
@@ -60,6 +60,15 @@
package Thrift::TException;
+use overload '""' => sub {
+ return
+ ref( $_[0] )
+ . " error: "
+ . ( $_[0]->{message} || 'empty message' )
+ . " (code "
+ . ( defined $_[0]->{code} ? $_[0]->{code} : 'undefined' ) . ")";
+ };
+
sub new {
my $classname = shift;
my $self = {message => shift, code => shift || 0};