joergd
1
Hi,
I have a begin rescue clause and want to trap for specific errors
begin
cause error
rescue Excpetion => err
case err
when SocketError
do stuff
when … # trap for ErrNo::EINVAL
end
end
Say I get the error ErrNo::EINVAL … how/where can I find out what the
Excpetion for it is named?
I have tries ErrNo::EINVAL, ErrNo::EINVALError, EINVALError, but none of
these seem to trap the exception …
Any help please
Thanks
Joerg
joergd
2
I found the answer in my PickAxe.
Errors like Errno:: are SystemCallErrors that the operating throws, and
they are contained in a module called Errno … <- note the small ‘n’.
So to trap an invalid argument error for example, use Errno::EINVAL
No need to append it with ‘Error’ either.
Sorry for noise.
Joerg D. wrote:
Hi,
I have a begin rescue clause and want to trap for specific errors
begin
cause error
rescue Excpetion => err
case err
when SocketError
do stuff
when … # trap for ErrNo::EINVAL
end
end
Say I get the error ErrNo::EINVAL … how/where can I find out what the
Excpetion for it is named?
I have tries ErrNo::EINVAL, ErrNo::EINVALError, EINVALError, but none of
these seem to trap the exception …
Any help please
Thanks
Joerg