From fe3bf927a2424a9192b448c19328ed99c9da53d2 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Thu, 25 Sep 2008 16:45:06 +0200 Subject: [PATCH] TinyURL: return the complete url if the TinyURL service fails --- lib/support/tinyurl.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/support/tinyurl.rb b/lib/support/tinyurl.rb index 6bf2389..7c19151 100644 --- a/lib/support/tinyurl.rb +++ b/lib/support/tinyurl.rb @@ -3,7 +3,11 @@ class TinyURL def self.tiny(url) return nil unless url http = Net::HTTP.start("tinyurl.com", 80) - response = http.post("/create.php", "url=#{url}") + begin + response = http.post("/create.php", "url=#{url}") + rescue Exception => e + return url + end if response.code == "200" body = response.read_body