Not able to catch psftp errors

Hi,
While running the psftp with the below code,it is able to connect and open the ftp connection and closed the connection.
But my scriptfile Test.ftp,is having the code "cd directoryname" where the directoryname does not exists.
In this case i should be able to catch the error,instead it is givving terun code 0(success) which belongs to closing connection.
how can i trap this error???

C:\\psftp.exe -v -i "C:\\filename.ppk" user@server.com -b "C:\\Test.ftp"

File "c:\\Test.ftp contains below code
cd directoryname_notexists
bye

ftp has numbers that appear in the output, they are called return codes.
ftp returns one of the numbers for every operation it attempts. You have to parse the output of the ftp session for error return codes.

The return code from the ftp process does not reflect what went on during the sesssion.

see List of FTP server return codes - Wikipedia, the free encyclopedia