PROTON-471: Reworked how Perl processes error results from API calls.

It does not die on qpid::proton::Errors::INPROGRESS.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ad96b59e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ad96b59e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ad96b59e

Branch: refs/heads/master
Commit: ad96b59ea1d7a137cdf4a0a3473885d5906dc7c0
Parents: 9186cb6
Author: Darryl L. Pierce <[email protected]>
Authored: Thu Dec 11 10:37:57 2014 -0500
Committer: Darryl L. Pierce <[email protected]>
Committed: Thu Dec 18 08:16:45 2014 -0500

----------------------------------------------------------------------
 .../perl/lib/qpid/proton/ExceptionHandling.pm   | 28 +++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad96b59e/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
----------------------------------------------------------------------
diff --git a/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm 
b/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
index 33cf6c0..00cdab1 100644
--- a/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
+++ b/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
@@ -20,21 +20,31 @@
 use strict;
 use warnings;
 use cproton_perl;
-use Devel::StackTrace;
+use Switch;
+
+use feature qw(switch);
 
 package qpid::proton;
 
 sub check_for_error {
     my $rc = $_[0];
 
-    if($rc < 0) {
-        my $source = $_[1];
-
-        my $trace = Devel::StackTrace->new;
-
-        print $trace->as_string;
-
-        die "ERROR[$rc] " . $source->get_error() . "\n";
+    switch($rc) {
+            case 'qpid::proton::Errors::NONE' {next;}
+            case 'qpid::proton::Errors::EOS' {next;}
+            case 'qpid::proton::Errors::ERROR' {next;}
+            case 'qpid::proton::Errors::OVERFLOW' {next;}
+            case 'qpid::proton::Errors::UNDERFLOW' {next;}
+            case 'qpid::proton::Errors::STATE' {next;}
+            case 'qpid::proton::Errors::ARGUMENT' {next;}
+            case 'qpid::proton::Errors::TIMEOUT' {next;}
+            case 'qpid::proton::Errors::INTERRUPTED' {
+                my $source = $_[1];
+                my $trace = Devel::StackTrace->new;
+
+                print $trace->as_string;
+                die "ERROR[$rc]" . $source->get_error() . "\n";
+            }
     }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to