Skip to content

Raise ArgumentError if Version is initialized with a nil version string#44

Open
timrogers wants to merge 1 commit into
jlindsey:masterfrom
timrogers:master
Open

Raise ArgumentError if Version is initialized with a nil version string#44
timrogers wants to merge 1 commit into
jlindsey:masterfrom
timrogers:master

Conversation

@timrogers

Copy link
Copy Markdown

At the moment, Semantic::Version.new raises a NoMethodError exception like this if you try to pass in nil as the version string:

undefined method `match' for nil:NilClass (NoMethodError)

v = version_str.match(SemVerRegexp)

This alters the behaviour to raise an ArgumentError instead, which is what we do if you pass a malformed string (e.g. dasd). This is a breaking change to the library's API - but it feels like a more reasonable and unsurprising behaviour.

…n string

At the moment, `Semantic::Version.new` raises a `NoMethodError`
exception like this if you try to pass in `nil` as the version
string:

```
undefined method `match' for nil:NilClass (NoMethodError)

v = version_str.match(SemVerRegexp)
```

This alters the behaviour to raise an `ArgumentError` instead,
which is what we do if you pass a malformed string (e.g.
`dasd`). This is a breaking change - but feels like a more
reasonable and unsurprising behaviour.
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

Successfully merging this pull request may close these issues.

1 participant