petercoles / Multilingual-Country-List

Laravel wrapper for generating country lookups and data objects using the awesome country-list data
MIT License
141 stars 33 forks source link

added check for file existence #1

Closed micron closed 7 years ago

micron commented 7 years ago

I ran into this issue passing the locale in uppercase. On an case insensitive file system there were no problems loading the locale file. On a case sensitive file system an exception was thrown. I think it's always saver to do a file_exists check before requiring files.

petercoles commented 7 years ago

Many thanks. That is useful feedback and raises some good points. I 100% agree that we should check that the file exists before trying to use it. I'm not so comfortable though with returning English if the file isn't found, especially in the example that you cited where the issue is the spelling of the locale.

Better, in my view, is that if the file isn't found, an exception should thrown explaining that we couldn't recognise the locale provided. This is better for debugging, as it avoids developers having to dig into the package to work out why when requesting Russian they got English, and it allows requests to be placed in a try/catch block so that any failures can be handled programmatically.

Release 1.2.2 now has this functionality.