I cannot get rescue to work

X

Xeno Campanoli

The example on page 108 of pickaxe gives me the following syntax error, for
instance:

../try4.rb:11: syntax error
rescue SystemCallError
^
xeno@linux:~/study/data>

Presumably there is something simple I'm doing wrong. Please make a
suggestion, as I'm really stuck.

xc
 
A

Assaph Mehr

Xeno said:
The example on page 108 of pickaxe gives me the following syntax error, for
instance:

./try4.rb:11: syntax error
rescue SystemCallError
^
xeno@linux:~/study/data>

Presumably there is something simple I'm doing wrong. Please make a
suggestion, as I'm really stuck.

Can you post the whole file, or at least the context in which this
statement is used?
Kinda hard to catch syntax errors without the code.
 
G

Gennady Bystritsky

Check your typing, you may have missed ), or end, or begin. Paste the
whole exercise, otherwise it is impossible to pin-point the problem.

Gennady.
 
X

Xeno Campanoli

Assaph said:
Xeno Campanoli wrote:



Can you post the whole file, or at least the context in which this
statement is used?
Kinda hard to catch syntax errors without the code.
Sorry, I tried to say before, I figured it out. It turns out you have
to put the rescue segment
on the bottom of the block, apparently, and I made it work when I did
that. I was however
fooled by the raise statement I left in afterwards. In taking out the
raise, and putting in
my own diagnostics, I now have mostly what I want, though it would be
nicer to get a line
number or statement indicator at the rescue point. For now I'm just
assigning the line to a
global to keep it around. If anyone can make a suggestion on that, it
would also be helpful.

Thanks to the several people who have helped me on this.

Sincerely,

Xeno
 
G

Gennady Bystritsky

If you want to know where the exception was originated from, you can
use Exception#backtrace method. With a little bit of parsing, you will
get a line number and a method name.

Gennady.
 
X

Xeno Campanoli

Gennady said:
If you want to know where the exception was originated from, you can
use Exception#backtrace method. With a little bit of parsing, you will
get a line number and a method name.
Thank you. I will try using that in my next draft. I'm trying to
finish one last piece of the first before I get horizontal tonight.

Sincerely, Xeno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top