Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws exception on lax version #31

Open
andk opened this issue Aug 29, 2016 · 2 comments
Open

Throws exception on lax version #31

andk opened this issue Aug 29, 2016 · 2 comments

Comments

@andk
Copy link
Member

andk commented Aug 29, 2016

This came to me a bit surprising. I cannot say whether it is a bug or feature. In my code I did not use eval and learned that I need it when I want to survive lax versions.

perl -E '
use CPAN::Meta::Requirements;
say "ok -- CMR version: $CPAN::Meta::Requirements::VERSION";
my $m = CPAN::Meta::Requirements->new;
$m->add_minimum(Foo => 1);
my $ok = eval { $m->accepts_module(Foo => "2.08a") };
say $ok ? "ok -- $ok" : "not ok -- $@";
'                                  
ok -- CMR version: 2.140
not ok -- Can't convert '2.08a': Invalid version format (non-numeric data)
@karenetheridge
Copy link
Member

I think CPAN::Meta::Requirements should be able to (more gracefully) reject non-compliant version strings in all of the APIs that take them (using the validation regex in CPAN::Meta::Validator::version).

@haarg
Copy link
Member

haarg commented Aug 30, 2016

What would "more gracefully" mean?

Throwing an exception like it currently does seems like the appropriate behavior to me. CPAN::Meta::Requirements->new also accepts a bad_version_hook option to do custom conversions on non-compliant versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants