Open gbprz opened 10 years ago
We're not catching the Timeout::Error, so it's bubbling all the way back up.
https://github.com/concerto/bandshell/blob/master/bin/bandshell-timer.rb
I suggest having a catch-all rescue block as shown here:
http://coderrr.wordpress.com/2008/11/07/the-simple-way-to-print-exceptions-in-ruby/
a rescue all is a very poor paradigm to follow. I'm pretty sure Yukihiro Matsumoto will stab us if we do that.
On Wed, Aug 13, 2014 at 1:34 AM, Kenley Cheung notifications@github.com wrote:
I suggest having a catch-all rescue block as shown here:
http://coderrr.wordpress.com/2008/11/07/the-simple-way-to-print-exceptions-in-ruby/
— Reply to this email directly or view it on GitHub https://github.com/concerto/bandshell/issues/29#issuecomment-52011565.
Yeah-I mean we're only using rescue here because there's not another clean choice. Every time you hit a rescue, you incur a massive performance hit in processing the exception; they're to be avoided at most any cost.
Upon further thought though, @khanh, if catching any exception is essential to continued operation of the screen, shouldn't we pursue that route whatever the style consequences?
@augustf, @khanh - As ugly as my suggestion is, keeping the screen running was the intent. We need to fail gracefully in case of a network failure.
that's fine, we can rescue Timeout::Error , but we shouldn't get in the lazy habit of catching all errors. my bestie yuki would be sad.. like a gray snowy day.
On Wed, Aug 13, 2014 at 9:38 PM, Kenley Cheung notifications@github.com wrote:
@augustf https://github.com/augustf, @khanh https://github.com/khanh
- As ugly as my suggestion is, keeping the screen running was the intent. We need to fail gracefully in case of a network failure.
— Reply to this email directly or view it on GitHub https://github.com/concerto/bandshell/issues/29#issuecomment-52134248.
On a bigger note, we're not the only parties facing this problem:
http://stackoverflow.com/questions/5370697/what-s-the-best-way-to-handle-exceptions-from-nethttp
It's been suggested to use an external HTTP library instead.
httparty or something similar sounds like a good idea.
Right now I'm working on pulling out all the API requests into a separate class so the code is a little less convoluted. Once I get that in, we should definitely try to implement some form of error handling here.
While testing a screen at RPI, one of our screens lost it's network connection. Rather than gracefully crashing or returning once a connection was regained, the screen crashed and left this error in the bandshell logs:
bandshelld.output
bandshell-timer.rb.output