begin do_some_things() rescue #... print message, closing file/socket etc. endThere is a problem with this style. If there is error, we lost information where it happens because it is quite common that
do_some_things()
again call methods of others classes located in different files and so all. I think that it should be a rule, that we alway print/save to logfile
backtrace
of exception in every exception handling code
begin do_some_things() rescue => e require 'pp' pp e pp e.backtrace #... print message, closing file/socket etc. endThe
backtrace
information will help us to identify bug during development and to analyze root cause of exception during operation.
No comments:
Post a Comment