After fast look at source code of this module I can suggest to use it like in example below. Because any method may raise exception. On http error this will be HTTP::Response object
eval {
my $response = $py->plot($x0, $y0, $x1, $y1);
};
if (my $err = $@) {
if (!ref $err) {
die "Plotly error: ", $err;
}
elsif ($err->isa('HTTP::Response')) {
die "HTTP error: ", $err->status_line;
}
else {
die "Unknown error: ", ref($err), " ($err)"
}
}