Amusingly enough, if you use Exception::Class and throw an error without a message, it has an overload that will stringify to undef, so "if ($@)" will in fact fail. The test against empty string will work though, even in this case. (And by the way, don't throw an Exception::Class error without a message.)