Try Catch blocks inside or outside of functions and error handing

前端 未结 6 595
野性不改
野性不改 2020-12-30 21:35

This is more a general purpose programming question than language specific. I\'ve seen several appraoches to try and catches.

One is you do whatever preprocessing on

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 22:20

    In general, an exception should only be caught if it can actually be handled.

    It makes no sense to catch an exception for no purpose other than to log it. The exception is that exceptions should be caught at the "top level" so that it can be logged. All other code should allow exceptions to propagate to the code that will log them.

提交回复
热议问题