$ftp->some_command(); if($ftp->code()==425){ # handle a "Can't open data connection." type error } #etc...