ruby - Alternative to "rescue Exception" -


i unexpected errors on occasion such timeout errors, 503 errors, etc. there errors don't know may receive. can't account of them doing like:

rescue timeout::error => e 

it's terrible idea rescue exception.

what alternative use? want code rescue of them when there error; if there no error, need avoided. want able kill script not skip on syntax errors, etc.

you can rescue standarderror, or rescue, same:

rescue standarderror => e # or rescue => e 

you can see in following table exceptions rescued standarderror - note subset exception, , conceitually should errors ok catch.

of course can have gems defines exception in wrong place, should not happen in well-developed gems.

ruby exceptions http://rubylearning.com/images/exception.jpg

i rescue exceptions know how handle, except when add in log/backtrace system consult errors later. if case, rescue standarderror


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -