Getting the exit code in a SystemExit rescue block?

L

Lloyd Zusman

Assume that I have the following code:

begin
exit(42)
rescue SystemExit => e
# How do I find out the argument passed to exit() here?
end

Inside of the `rescue' block, is there any way for me to find out the
argument that was passed to exit()? In this example, I'd want to know
that `42' was passed.

Thanks in advance.
 
Y

Yukihiro Matsumoto

In message "Re: Getting the exit code in a SystemExit rescue block?"

| begin
| exit(42)
| rescue SystemExit => e
| # How do I find out the argument passed to exit() here?
p e.status
| end

matz.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top