Skip to content

Instantly share code, notes, and snippets.

@typester
Created September 17, 2009 10:23
Show Gist options
  • Save typester/188437 to your computer and use it in GitHub Desktop.
Save typester/188437 to your computer and use it in GitHub Desktop.
From 837ffd5cd282df217863cb5593271d66308d4bd7 Mon Sep 17 00:00:00 2001
From: Daisuke Murase <typester@cpan.org>
Date: Thu, 17 Sep 2009 19:21:44 +0900
Subject: [PATCH] add on_error to stream handler
---
lib/AnyEvent/Twitter/Stream.pm | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/AnyEvent/Twitter/Stream.pm b/lib/AnyEvent/Twitter/Stream.pm
index 31971b3..fbbdc57 100644
--- a/lib/AnyEvent/Twitter/Stream.pm
+++ b/lib/AnyEvent/Twitter/Stream.pm
@@ -77,6 +77,10 @@ sub new {
Scalar::Util::weaken($self);
if ($handle) {
+ $handle->on_error(sub {
+ undef $handle;
+ $on_error->(@_);
+ });
$handle->on_eof(sub {
undef $handle;
$on_eof->(@_);
--
1.6.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment