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

added check for file existence #1

Closed
wants to merge 1 commit into from
Closed

Conversation

micron
Copy link

@micron micron commented Mar 31, 2017

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.

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
Copy link
Owner

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.

@petercoles petercoles closed this Jul 16, 2017
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.

2 participants