# How I can trap FTPPermError?

**URL:** <https://www.ruby-forum.com/t/how-i-can-trap-ftppermerror/162732>\
**Category:** Ruby\
**Created:** [March 13, 2009, 9:07am UTC](https://www.ruby-forum.com/t/how-i-can-trap-ftppermerror/162732 "2009-03-13T09:07:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [March 13, 2009, 9:07am UTC](https://www.ruby-forum.com/t/how-i-can-trap-ftppermerror/162732/1 "2009-03-13T09:07:54Z")

</div>

Hello,

I’m trying to access an FTP tp check if the files from database exists  
there, and if they have valid size.

Some of them are wrong files with zero kbytes.

My script stops with:

10944/10948 11978 inf\_A78028800\_12032009153806.pdf VOS200-SAL04

Net::FTPPermError: 550 Can’t check for file existence

I want to trap the FTPPermError and continue with other files …

I’ve tried with:

FTPPermError  
Net::FTPPermError

witha Rescue but the scripts stops and those rescues doesn’t fire …

thanks!

r.

…

begin

size=ftp.size(file\_name)  
print “File size file: “+size.to\_s+”\n”

ftp.getbinaryfile(file\_name, file\_name\_result, 1024)

rescue FTPPermError, NameError =\> aaaapppppoooooo  
return false

rescue Net::FTPPermError, NameError =\> ooooops  
return false

rescue StandardError, NameError =\> boom

# print "Error while downloading: " + boom

#status=false  
return false

end

…
