summaryrefslogtreecommitdiff
path: root/lib/perl
diff options
context:
space:
mode:
authorRoger Meier <roger@apache.org>2016-01-25 22:26:39 +0100
committerRoger Meier <roger@apache.org>2016-01-25 22:26:39 +0100
commit45c8e4935740292b8253041195ed5913d1c796b1 (patch)
tree0ce810e93e01565e963597583b3fed5693995aa7 /lib/perl
parent41e4847786a68219263b7450573a4fce5c92672b (diff)
downloadthrift-45c8e4935740292b8253041195ed5913d1c796b1.tar.gz
THRIFT-3549 Exceptions are not properly stringified in Perl library
Patch: David Morel
Diffstat (limited to 'lib/perl')
-rw-r--r--lib/perl/lib/Thrift.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm
index 5cabd80d2..bd7b65a7d 100644
--- a/lib/perl/lib/Thrift.pm
+++ b/lib/perl/lib/Thrift.pm
@@ -60,6 +60,15 @@ use constant ONEWAY => 4;
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};