Subject: | Net::Twitter::Error fails with Can't locate object method "blessed" via package "Net::Twitter::Error" |
I think this is because I have updated my version of Moose:
Moose Changes 0.93_01 Mon, Jan 4, 201 "The unimport subs created by
Moose::Exporter now clean up re-exported functions like blessed and
confess, unless the caller imported them from somewhere else too. See
Moose::Manua::Delta for backcompat details. (rafl)"
and Net::Twitter::Error does not import blessed. So I guess previously
it was silently inheriting it.
Attached script (test.pl) reproduces the error.
A possible workaround is to add
use Scalar::Util qw/blessed/;
to your script.
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Moose 0.93_01;
use Net::Twitter;
# use Scalar::Util qw/blessed/;
my $nt = Net::Twitter->new(
traits => [qw/API::REST/],
username => 'homer',
password => 'doh!',
);
eval {
my $statuses = $nt->friends_timeline(); # will fail cos of authentication
};
if ($@) {
if ( blessed $@ && $@->isa('Net::Twitter::Error') ) {
warn "Net::Twitter::Error - $@->error";
}
else {
warn "NOT a Net::Twitter::Error - $@";
}
}