my $result = $object->method();
unless(defined($result)) {
$log->error("Something's gone wrong when called $object->method(): " . $object->error_message);
# ...doing something with that...
}
####
my $result = $object->method();
if($object->has_error) {
$log->error("Something's gone wrong when called $object->method(): " . $object->error_message);
# ...doing something with that...
}
# ...doing something else, understanding that the method just doesn't have anything to pass to us...
####
my $result = eval { $object->method() };
if($@) {
$log->error("Something's gone wrong when called $object->method(): $@");
# ...doing something with that...
}
# ...doing something else, understanding that the method just doesn't have anything to pass to us...