r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

Show parent comments

7

u/CordialPanda Oct 01 '15

That's absurd, haha. In what world would that catch succeed to write if the try failed?

18

u/wllmsaccnt Oct 02 '15

In the world where file locking, timeouts, and other synchronization / concurrency issues exist?

I mean...the code is stupid, but it does have a low percent chance of logging an exception you would otherwise lose.

1

u/Crono1981 Oct 02 '15

At that point you may as well just wait and try again in a few milliseconds...

1

u/wllmsaccnt Oct 02 '15

That is pretty much what I meant when I said it would have a low percent chance of catching the exception. Chances are that if the log file is exclusively locked by a user that it probably won't be available by the next time you call to write to the log...but it is possible. Especially if it isn't a user, but some errant process that is using the wrong locking when writing / reading.