Return statements in catch blocks

后端 未结 6 1502
渐次进展
渐次进展 2021-01-13 05:29

I have seen some developers use the return statement in a catch block. Why/when would this be a useful technique to employ?

EDIT: I actually just saw the return keyw

6条回答
  •  孤城傲影
    2021-01-13 06:31

    You might want to catch the error, log it and say return a value of false which indicates if the function was successful. In other situations you might want to return some data which was calculated in the try block

提交回复
热议问题