The easiest way to catch perl exception is to use Try::Tiny
Here's an example:
use Try::Tiny;
try
{
#put your normal code here or the code that you think might generate exception
$sftp=Net::SFTP->new($SERVER_NAME, %sftp_args) or die "Cannot connect to sftp server";
}
catch
{
#catch the exception and execute your exception handling code here such as printing a custom error
print "Cannot connect to sftp server";
exit;
};