I've caught an exception!! Now what?

后端 未结 16 949
逝去的感伤
逝去的感伤 2021-02-02 05:15

I\'ve started using try-catch blocks (a bit late, I know!), but now I\'m not sure what to do with the exception once I\'ve caught it. What should I do?



        
16条回答
  •  面向向阳花
    2021-02-02 05:45

    FYI, you don't have to use the catch to have a finally statement.

    Sometimes people throw a new exception that is more firendly and add the original exception as the inner exception.

    Often this is used to log the error to a file or send an email to an operator.

    Sometimes, especially with SQL, it may just mean a duplicate key which means, for example, please choose another username, that one is already taken - it's all down to your application.

提交回复
热议问题