when do I write my own exception class?

后端 未结 4 1192
感情败类
感情败类 2021-02-02 12:00

I have been wondering since I stepped into the murky waters of OOP and have written a couple or so of distributed libraries when it is necessary to write my own extension of the

4条回答
  •  迷失自我
    2021-02-02 12:41

    The built in exception is good enough for almost every case. The only scenario that I could think of where you need another one is when there are more than one exception that can be thrown in a try and you want to do different things depending of which one is thrown. You have to distinguish two exceptions. therefore you need another one.

提交回复
热议问题