From: Panagiotis Atmatzidis Date: 2012-08-09T04:43:55+09:00 Subject: Re: Exception handling doesn't work Hello, On 8 Αυγ 2012, at 22:23 , Justin Collins wrote: > On 08/08/2012 12:14 PM, Panagiotis Atmatzidis wrote: >> Hello, >> >> I'm trying to handle an two different exception cases. Using the 'twitter' gem I have the two following exceptions. >> >> Here is the code: https://gist.github.com/3297666 >> >> Using irb (ruby 1.9.3x) I get : >> >> "Twitter::Error::ClientError" - when no internet connection is available and >> "Twitter::Error::NotFound" - when username is not found, the supplied twitter username does not exist. >> >> However, no matter what the program goes with the 1st exception. Even when the error is "Twitter::Error::NotFound". >> >> What am I doing wrong? >> > > You are not doing anything wrong. This is happening because Twitter::Error::NotFound inherits from Twitter::Error::ClientError and `rescue` will rescue any subclasses of the provided class. > > Try reversing the order of your rescue clauses. Thanks for the prompt reply! It worked fine! :-) > -Justin > > > Panagiotis Atmatzidis ----------------------------- Pharmacy Student at VFU email4lists: ml@convalesco.org More info: http://about.me/atmosx The wise man said: "Never argue with an idiot, he brings you down to his level and beat you with experience."