You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2016/01/25 22:27:50 UTC

thrift git commit: THRIFT-3549 Exceptions are not properly stringified in Perl library

Repository: thrift
Updated Branches:
  refs/heads/master 41e484778 -> 45c8e4935


THRIFT-3549 Exceptions are not properly stringified in Perl library

Patch: David Morel


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/45c8e493
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/45c8e493
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/45c8e493

Branch: refs/heads/master
Commit: 45c8e4935740292b8253041195ed5913d1c796b1
Parents: 41e4847
Author: Roger Meier <ro...@apache.org>
Authored: Mon Jan 25 22:26:39 2016 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Mon Jan 25 22:26:39 2016 +0100

----------------------------------------------------------------------
 lib/perl/lib/Thrift.pm | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/45c8e493/lib/perl/lib/Thrift.pm
----------------------------------------------------------------------
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 @@ 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};