When is it OK to catch a RuntimeException

前端 未结 10 1102
眼角桃花
眼角桃花 2020-12-07 11:03

On a recent project I recommended catching a RuntimeException within a test harness code and logging it. The code processes a series of inputs from a database, and I do not

10条回答
  •  不思量自难忘°
    2020-12-07 11:38

    You catch RuntimeException when you want to process it. Maybe you want to rethrow it as a different exception or log it to a file or database, or you want to turn on some exception flag in the return type, etc.

提交回复
热议问题