You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/12/02 20:14:54 UTC
svn commit: r1547155 - in /qpid/proton/trunk/proton-c/bindings/perl:
ChangeLog lib/qpid/proton/Constants.pm lib/qpid/proton/ExceptionHandling.pm
lib/qpid/proton/Messenger.pm lib/qpid_proton.pm
Author: mcpierce
Date: Mon Dec 2 19:14:54 2013
New Revision: 1547155
URL: http://svn.apache.org/r1547155
Log:
PROTON-458: Perl Messenger now dies on error conditions.
Added the qpid::proton::check_for_errors() method that takes the return
code of a method and dies if the value is an error.
Added:
qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
- copied, changed from r1547100, qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm
Modified:
qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Constants.pm
qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm
qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm
Modified: qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/ChangeLog?rev=1547155&r1=1547154&r2=1547155&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/ChangeLog (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/ChangeLog Mon Dec 2 19:14:54 2013
@@ -1,6 +1,7 @@
version 0.7:
* PROTON-457: Add interrupt method to Messenger.
* PROTON-463: Add qpid::proton::Tracker type.
+ * PROTON-458: Perl dies on error.
version 0.6:
* qpid::proton::Messenger returns incoming trackers on get.
Modified: qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Constants.pm
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Constants.pm?rev=1547155&r1=1547154&r2=1547155&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Constants.pm (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Constants.pm Mon Dec 2 19:14:54 2013
@@ -138,4 +138,19 @@ use constant {
"get_map_helper"),
};
+package qpid::proton::Errors;
+
+use constant {
+ NONE => 0,
+ EOS => $cproton_perl::PN_EOS,
+ ERROR => $cproton_perl::PN_ERR,
+ OVERFLOW => $cproton_perl::PN_OVERFLOW,
+ UNDERFLOW => $cproton_perl::PN_UNDERFLOW,
+ STATE => $cproton_perl::PN_STATE_ERR,
+ ARGUMENT => $cproton_perl::PN_ARG_ERR,
+ TIMEOUT => $cproton_perl::PN_TIMEOUT,
+ INTERRUPTED => $cproton_perl::PN_INTR,
+ INPROGRESS => $cproton_perl::PN_INPROGRESS,
+};
+
1;
Copied: qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm (from r1547100, qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm?p2=qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm&p1=qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm&r1=1547100&r2=1547155&rev=1547155&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm Mon Dec 2 19:14:54 2013
@@ -21,14 +21,16 @@ use strict;
use warnings;
use cproton_perl;
-use qpid::proton::Data;
-use qpid::proton::Mapping;
-use qpid::proton::Constants;
-use qpid::proton::Tracker;
-use qpid::proton::Messenger;
-use qpid::proton::Message;
+package qpid::proton;
-use qpid::proton;
+sub check_for_error {
+ my $rc = $_[0];
-1;
+ if($rc < 0) {
+ my $source = $_[1];
+
+ die "ERROR[$rc] " . $source->get_error();
+ }
+}
+1;
Modified: qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm?rev=1547155&r1=1547154&r2=1547155&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm Mon Dec 2 19:14:54 2013
@@ -67,7 +67,7 @@ sub set_outgoing_window {
$window = 0 if !defined($window);
$window = int($window);
- cproton_perl::pn_messenger_set_outgoing_window($self->{_impl}, $window);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_set_outgoing_window($self->{_impl}, $window), $self);
}
sub get_outgoing_window {
@@ -75,14 +75,14 @@ sub get_outgoing_window {
return cproton_perl::pn_messenger_get_outgoing_window($self->{_impl});
}
-sub set_incoming_window {
+sub set_incoming_window{
my ($self) = @_;
my $window = $_[1];
$window = 0 if !defined($window);
$window = int($window);
- cproton_perl::pn_messenger_set_incoming_window($self->{_impl}, $window);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_set_incoming_window($self->{_impl}, $window), $self);
}
sub get_incoming_window {
@@ -102,12 +102,12 @@ sub get_errno {
sub start {
my ($self) = @_;
- cproton_perl::pn_messenger_start($self->{_impl});
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_start($self->{_impl}), $self);
}
sub stop {
my ($self) = @_;
- cproton_perl::pn_messenger_stop($self->{_impl});
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_stop($self->{_impl}), $self);
}
sub subscribe {
@@ -138,7 +138,7 @@ sub get_private_key {
sub set_password {
my ($self) = @_;
- cproton_perl::pn_messenger_set_password($self->{_impl}, $_[1]);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_set_password($self->{_impl}, $_[1]), $self);
}
sub get_password {
@@ -163,7 +163,7 @@ sub put {
$message->preencode();
my $msgimpl = $message->get_impl();
- cproton_perl::pn_messenger_put($impl, $msgimpl);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_put($impl, $msgimpl), $self);
my $tracker = $self->get_outgoing_tracker();
return $tracker;
@@ -185,7 +185,7 @@ sub send {
my ($self) = @_;
my $n = $_[1];
$n = -1 if !defined $n;
- cproton_perl::pn_messenger_send($self->{_impl}, $n);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_send($self->{_impl}, $n), $self);
}
sub get {
@@ -193,7 +193,7 @@ sub get {
my $impl = $self->{_impl};
my $message = $_[1] || new proton::Message();
- cproton_perl::pn_messenger_get($impl, $message->get_impl());
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_get($impl, $message->get_impl()), $self);
$message->postdecode();
my $tracker = $self->get_incoming_tracker();
@@ -216,13 +216,13 @@ sub receive {
my ($self) = @_;
my $n = $_[1];
$n = -1 if !defined $n;
- cproton_perl::pn_messenger_recv($self->{_impl}, $n);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_recv($self->{_impl}, $n), $self);
}
sub interrupt {
my ($self) = @_;
- return cproton_perl::pn_messenger_interrupt($self->{_impl});
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_interrupt($self->{_impl}), $self);
}
sub outgoing {
@@ -243,7 +243,7 @@ sub accept {
$tracker = cproton_perl::pn_messenger_incoming_tracker($self->{_impl});
$flags = $cproton_perl::PN_CUMULATIVE;
}
- return cproton_perl::pn_messenger_accept($self->{_impl}, $tracker, $flags);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_accept($self->{_impl}, $tracker, $flags), $self);
}
sub reject {
@@ -254,7 +254,7 @@ sub reject {
$tracker = cproton_perl::pn_messenger_incoming_tracker($self->{_impl});
$flags = $cproton_perl::PN_CUMULATIVE;
}
- return cproton_perl::pn_messenger_reject($self->{_impl}, $tracker, $flags);
+ qpid::proton::check_for_error(cproton_perl::pn_messenger_reject($self->{_impl}, $tracker, $flags), $self);
}
sub status {
Modified: qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm?rev=1547155&r1=1547154&r2=1547155&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/lib/qpid_proton.pm Mon Dec 2 19:14:54 2013
@@ -21,6 +21,7 @@ use strict;
use warnings;
use cproton_perl;
+use qpid::proton::ExceptionHandling;
use qpid::proton::Data;
use qpid::proton::Mapping;
use qpid::proton::Constants;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org