{"action":"opened","issue":{"url":"https://api.github.com/repos/c-rack/cidr-elixir/issues/5","labels_url":"https://api.github.com/repos/c-rack/cidr-elixir/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/c-rack/cidr-elixir/issues/5/comments","events_url":"https://api.github.com/repos/c-rack/cidr-elixir/issues/5/events","html_url":"https://github.com/c-rack/cidr-elixir/issues/5","id":113231622,"number":5,"title":"match/2 needs better error handling","user":{"login":"duijf","id":1123589,"avatar_url":"https://avatars.githubusercontent.com/u/1123589?v=3","gravatar_id":"","url":"https://api.github.com/users/duijf","html_url":"https://github.com/duijf","followers_url":"https://api.github.com/users/duijf/followers","following_url":"https://api.github.com/users/duijf/following{/other_user}","gists_url":"https://api.github.com/users/duijf/gists{/gist_id}","starred_url":"https://api.github.com/users/duijf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duijf/subscriptions","organizations_url":"https://api.github.com/users/duijf/orgs","repos_url":"https://api.github.com/users/duijf/repos","events_url":"https://api.github.com/users/duijf/events{/privacy}","received_events_url":"https://api.github.com/users/duijf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-25T15:13:59Z","updated_at":"2015-10-25T15:13:59Z","closed_at":null,"body":"Currently, match just returns `true` or `false`. However, it would be good to let callers know if there is an error in the ip-address they passed in. Currently `CIDR.match(cidr, :test)` returns `false`, but `CIDR.match(cidr, \"this should be an ip address\") throws a matcherror.\r\n\r\nYou can also pass in any 4 or 6 tuple and there will not be any validation.\r\n\r\nThe way I see it, we can pick from two approaches:\r\n\r\nTuple reporting:\r\n\r\n - When it's a match: `{:ok, true}`\r\n - When it's not a match: `{:ok, false}`\r\n - When the IP to match against is invalid: `{:error, reason}`.\r\n\r\nExceptions:\r\n\r\n - When it's a match: `true`\r\n - When it's not a match: `false`\r\n - When the IP to match against is invalid: `raise ArgumentError`.\r\n\r\nWe can also support both, separate by function name: `match` for the first interface and `match!` for the second."}}