I've caught an exception!! Now what?

后端 未结 16 915
逝去的感伤
逝去的感伤 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:55

    It depends on what the SQL does really. Is it something:

    • that the user did? Perhaps create an account or a message - then you need to inform the user that something is wrong
    • that the application does naturally? Like cleaning up logs or something similar? Is it fatal? Can the application go on? Is it something that can be ignored - perhaps retried? Should the administrator be announced?

    Start with these questions, they will usually lead to answers about how to treat exceptions

提交回复
热议问题