[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88

Tomas Doran bobtfish at bobtfish.net
Mon May 6 11:57:41 UTC 2013


The following commit has been merged in the master branch:
commit 0ecc0a5f54b697d8d848d3379be9780610b48fdc
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sun Aug 26 21:09:50 2012 +0100

    Use more structured exceptions in the normal roles

diff --git a/lib/Message/Passing/Exception/ConnectionDisconnected.pm b/lib/Message/Passing/Exception/ConnectionDisconnected.pm
new file mode 100644
index 0000000..c7fc083
--- /dev/null
+++ b/lib/Message/Passing/Exception/ConnectionDisconnected.pm
@@ -0,0 +1,21 @@
+package Message::Passing::Exception::ConnectionDisconnected;
+use Moo;
+use Data::Dumper ();
+use namespace::clean -except => 'meta';
+
+with 'Message::Passing::Exception';
+
+1;
+
+=head1 NAME
+
+Message::Passing::Exception::ConnectionDisconnected - A connection disconnected
+
+=head1 ATTRIBUTES
+
+=head1 AUTHOR, COPYRIGHT AND LICENSE
+
+See L<Message::Passing>.
+
+=cut
+
diff --git a/lib/Message/Passing/Exception/ConnectionTimeout.pm b/lib/Message/Passing/Exception/ConnectionTimeout.pm
new file mode 100644
index 0000000..636241f
--- /dev/null
+++ b/lib/Message/Passing/Exception/ConnectionTimeout.pm
@@ -0,0 +1,32 @@
+package Message::Passing::Exception::ConnectionTimeout;
+use Moo;
+use Data::Dumper ();
+use MooX::Types::MooseLike::Base qw/ Str Num /;
+use namespace::clean -except => 'meta';
+
+with 'Message::Passing::Exception';
+
+has after => (
+    isa => Num,
+    is => 'ro',
+    required => 1,
+);
+
+1;
+
+=head1 NAME
+
+Message::Passing::Exception::ConnectionTimeout - A connection timed out
+
+=head1 ATTRIBUTES
+
+=head2 after
+
+How long we waited before the connection was timed out.
+
+=head1 AUTHOR, COPYRIGHT AND LICENSE
+
+See L<Message::Passing>.
+
+=cut
+
diff --git a/lib/Message/Passing/Role/ConnectionManager.pm b/lib/Message/Passing/Role/ConnectionManager.pm
index 2d9631d..3da3752 100644
--- a/lib/Message/Passing/Role/ConnectionManager.pm
+++ b/lib/Message/Passing/Role/ConnectionManager.pm
@@ -3,6 +3,8 @@ use Moo::Role;
 use MooX::Types::MooseLike::Base qw/ Bool ArrayRef /;
 use Scalar::Util qw/ blessed weaken /;
 use Carp qw/ confess /;
+use Message::Passing::Exception::ConnectionDisconnected;
+use Message::Passing::Exception::ConnectionTimeout;
 use namespace::clean -except => 'meta';
 
 requires '_build_connection';
@@ -48,7 +50,9 @@ sub _build_timeout_timer {
     AnyEvent->timer(
         after => $self->timeout,
         cb => sub {
-            $self->error->consume("Connection timed out to ...");
+            $self->error->consume(Message::Passing::Exception::ConnectionTimeout->new(
+                after => $self->timeout,
+            ));
             $self->_timeout_timer(undef);
             $self->_set_connected(0); # Use public API, causing reconnect timer to be built
         },
@@ -61,7 +65,7 @@ sub _build_reconnect_timer {
     AnyEvent->timer(
         after => $self->reconnect_after,
         cb => sub {
-            $self->error->consume("Reconnecting to ...");
+#            $self->error->consume("Reconnecting to ...");
             $self->_timeout_timer(undef);
             $self->connection; # Just rebuild the connection object
         },
@@ -108,7 +112,7 @@ after _set_connected => sub {
     }
     $self->_timeout_timer(undef) if $connected;
     if (!$connected && $self->_has_connection) {
-        $self->error->consume("Connection disconnected to ...");
+        $self->error->consume(Message::Passing::Exception::ConnectionDisconnected->new);
         $self->_clear_connection;
     }
 };
@@ -213,4 +217,4 @@ the SureVoIP API -
 
 See L<Message::Passing>.
 
-=cut
\ No newline at end of file
+=cut

-- 
libmessage-passing-perl Debian packaging



More information about the Pkg-perl-cvs-commits mailing list