Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Programmatically and dynamically catching exceptions

Reply
Thread Tools

Programmatically and dynamically catching exceptions

 
 
Zach Dennis
Guest
Posts: n/a
 
      11-05-2004
I haven't seen a reply to this thread, so I'll give it one more go.....

When I rescue an Exception shouldn't it be my responsiblity as the
developer to handle it and print it to STDOUT or STDERR? Why does Ruby
1.8.2 still output something to STDERR!!? Is this just how it works?

Zach

----CODE-----
class MyException < Exception; end

def method
raise MyException
end

begin
method
rescue MyException
#shouldn't this rescue the error?
# --Why does it still get outputted to my screen?
end


 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      11-05-2004
Zach Dennis wrote:
> I haven't seen a reply to this thread, so I'll give it one more go.....
>
> When I rescue an Exception shouldn't it be my responsiblity as the
> developer to handle it and print it to STDOUT or STDERR? Why does Ruby
> 1.8.2 still output something to STDERR!!? Is this just how it works?
>
> Zach
>
> ----CODE-----
> class MyException < Exception; end
>
> def method
> raise MyException
> end
>
> begin
> method
> rescue MyException
> #shouldn't this rescue the error?
> # --Why does it still get outputted to my screen?
> end


Are you sure that code, exactly, prints something to stderr or stdout? I
can't reproduce it here with 1.8.2 or 1.9 snapshots.


 
Reply With Quote
 
 
 
 
Zach Dennis
Guest
Posts: n/a
 
      11-05-2004
Joel VanderWerf wrote:

> Zach Dennis wrote:
>
>> I haven't seen a reply to this thread, so I'll give it one more go.....
>>
>> When I rescue an Exception shouldn't it be my responsiblity as the
>> developer to handle it and print it to STDOUT or STDERR? Why does
>> Ruby 1.8.2 still output something to STDERR!!? Is this just how it
>> works?
>>
>> Zach
>>
>> ----CODE-----
>> class MyException < Exception; end
>>
>> def method
>> raise MyException
>> end
>>
>> begin
>> method
>> rescue MyException
>> #shouldn't this rescue the error?
>> # --Why does it still get outputted to my screen?
>> end

>
>
> Are you sure that code, exactly, prints something to stderr or stdout?
> I can't reproduce it here with 1.8.2 or 1.9 snapshots.


Joel you are a lifesaver. Thank you for responding....I stepped out of
my IDE shell and test just via command line. And you are correct, it
doesn't print to stdout or stderr. So then I looked at the difference
between how my IDE was running Ruby and me personally on the CLI. The
debug "-d" option made the difference when calling Ruby. Bah, I guess
that is what happens when you get real comfortable in an IDE.

Thanks so much Joel for responding, otherwise I'd probably still be at
this minor roadblock tomorrow!

Zach


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
defining, raising and catching exceptions Chris Hare Python 0 08-05-2010 10:41 PM
worker thread catching exceptions and putting them in queue Paul Sijben Python 5 03-08-2007 08:36 PM
Catching unhandled exceptions using HttpModules Amil Hanish ASP .Net 0 04-12-2006 11:51 PM
Try blocks and not catching exceptions Adam H. Peterson C++ 8 01-27-2004 11:34 PM
Re: catching exceptions from web user controls Marina ASP .Net 2 07-08-2003 04:48 PM



Advertisments