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

Don't crash on non-writable logger file #160

Merged
merged 1 commit into from
Sep 26, 2016

Conversation

tombruijn
Copy link
Member

@tombruijn tombruijn commented Sep 20, 2016

When the parent path is writable, but the logger file itself is not, do no longer crash.

Also updated specs to be more descriptive and cover more cases.

Based on #158
Part of fix for #153

begin
@logger = Logger.new(path)
@logger.formatter = log_formatter
rescue Exception => error
Copy link
Member

@jeffkreeftmeijer jeffkreeftmeijer Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I agree that we should be careful here, we probably don't want to rescue Exception and turn it into a warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what all the errors that can be thrown here, so I'll change it to StandardError using rescue => e.

Not sure why I thought rescuing Exception was a good thing, especially since we discussed it earlier.. 🤔

@tombruijn tombruijn force-pushed the catch-logger-file-permission-errors branch 2 times, most recently from a39dfbd to c4a355a Compare September 22, 2016 10:15
@tombruijn tombruijn force-pushed the catch-logger-file-permission-errors branch from c4a355a to 7e871c9 Compare September 22, 2016 14:55
@tombruijn tombruijn changed the base branch from log_file_path-improvements to master September 22, 2016 14:55
@tombruijn
Copy link
Member Author

Rebased on updated master

@tombruijn tombruijn force-pushed the catch-logger-file-permission-errors branch 2 times, most recently from 724e7b2 to 05119f9 Compare September 23, 2016 09:45
@tombruijn
Copy link
Member Author

Updated to rescue on SystemCallError. Seems to encapsulate most IO errors we can trigger

When the parent path is writable, but the logger file itself is not, do
no longer crash.

Also updated specs to be more descriptive and cover more cases.
@tombruijn tombruijn force-pushed the catch-logger-file-permission-errors branch from 05119f9 to bd90694 Compare September 26, 2016 07:04
@tombruijn tombruijn merged commit 8459ec4 into master Sep 26, 2016
@tombruijn tombruijn deleted the catch-logger-file-permission-errors branch September 26, 2016 08:02
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.

None yet

3 participants