country-code-lookup icon indicating copy to clipboard operation
country-code-lookup copied to clipboard

throw Error for ISO search

Open triori opened this issue 2 years ago • 2 comments

Hi there, My point if you return null in other case, why you throw new Error in ISO case? throw new Error('cannot determine ISO code type') in ISO case VS return null for other cases. I think it is unexpectable result, isn't it?

triori avatar May 24 '23 09:05 triori

I agree that there is some inconsistency here, but the error indicates that the input format is possibly wrong, the other indicates that there isn't a match (another way for the input being wrong I suppose).

Happy to change this behaviour with an update to the major version number to represent a change in the API

richorama avatar Jun 09 '23 11:06 richorama

At minimum I think that the behavior should be documented. Especially if you stick to throwing an Error.

jjsimps avatar Jun 15 '23 00:06 jjsimps