LibreCat / Catmandu-BagIt

Catmandu module for working with BagIt packages
Other
1 stars 1 forks source link

Catmanu::BagIt->read should return errors in array context #6

Closed nicolasfranck closed 7 years ago

nicolasfranck commented 7 years ago

Now the read method from Catmandu::Bagit only returns an object or undef

my $bagit = Catmandu::BagIt->read($path)

In array context it should also return the errors:

my($bagit,@errors) = Catmandu::BagIt->read($path)

Which can be done easily:

sub read {
  #..
  if ( wantarray ) {
    #new code
    return $ok == 7 ? ($self) : (undef, $self->errors);
  }
  else {
    #old code
    return $ok == 7 ? $self : undef;
  }

}