Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby exception statement not suppressed within begin-rescue-end block

Reply
Thread Tools

Ruby exception statement not suppressed within begin-rescue-end block

 
 
RichardOnRails
Guest
Posts: n/a
 
      09-11-2010
HI,

I've got the code below. it creates the output:

Exception `NameError' at ReformChartNames.rb:8 - uninitialized
constant DATA
"__END__" statement or subsequent directory-name missing
Quitting job

I thought the "Exception" statement should not be generated because I
rescued from and errors. So, what's up?

Thanks in Advance,
Richard

=== code ===
[snip]
$DEBUG = true
$source_directory_name

begin
$source_directory_name =
DATA.readline # Line # 8
rescue
puts %<"__END__" statement or subsequent directory-name missing
\nQuitting job>
STDOUT.flush
exit
end

class ReformChartNames
def initialize
@source_dir_name = $source_directory_name.chomp
unless File.directory?(@source_dir_name)
puts %<ERROR: "%s" is not a valid directory name> %
[@source_dir_name]
exit
end
end
end


rcn = ReformChartNames.new
puts %<Got ReformChartNames object "rcn"> if $DEBUG

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      09-11-2010
A bare 'rescue' is short for 'rescue StandardError', and catches only
sunglasses of that. If you want to rescue everything then 'rescue
Exception', but beware that also catches programmer errors, system
problems like out of memory etc.

Google "ruby exception hierarchy" for more.

To use DATA, put __END__ at the end of your code followed by the data
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ryan Davis
Guest
Posts: n/a
 
      09-11-2010

On Sep 10, 2010, at 23:52 , Brian Candler wrote:

> A bare 'rescue' is short for 'rescue StandardError', and catches only
> sunglasses of that. If you want to rescue everything then 'rescue
> Exception', but beware that also catches programmer errors, system
> problems like out of memory etc.
>
> Google "ruby exception hierarchy" for more.
>
> To use DATA, put __END__ at the end of your code followed by the data


sunglasses?

voice transcription?



 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      09-11-2010
> Sunglasses?

Android phone and touch screen keyboard
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
RichardOnRails
Guest
Posts: n/a
 
      09-27-2010
On Sep 11, 2:52*am, Brian Candler <b.cand...@pobox.com> wrote:
> A bare 'rescue' is short for 'rescue StandardError', and catches only
> sunglasses of that. If you want to rescue everything then 'rescue
> Exception', but beware that also catches programmer errors, system
> problems like out of memory etc.
>
> Google "ruby exception hierarchy" for more.
>
> To use DATA, put __END__ at the end of your code followed by the data
> --
> Posted viahttp://www.ruby-forum.com/.


Hi Brian,

Thanks for your excellent response, not withstanding the sunglasses I
must have been wearing when I screwed up My delay in
responding, for which I apologize, occurred because I distracted by
another project.

Best wishes,
Richard
 
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
Re: This evil ... it will be suppressed iL_WeReo Computer Support 0 05-05-2009 07:27 AM
Re: This evil ... it will be suppressed Dan C Computer Support 0 05-04-2009 02:18 AM
SPACE is suppressed Saeed HTML 3 10-23-2008 10:35 PM
SPACES suppressed Saeed HTML 0 10-22-2008 11:29 PM
Const symbols suppressed PlayDough C++ 2 01-19-2008 04:30 AM



Advertisments