Java – why project specific runtimeException?

There is a com myco. myproj. Does myprojruntimeexception have any meaning,

Solution

Yes Throw unchecked exceptions and subclass them

There is a lot of discussion about whether checking for exceptions does have any benefits In short, if I throw a checked exception, does my customer really have anything to do with it?

Unchecked exceptions are a good way to notify customers of exceptions (including illegal preconditions), and do not burden API calls that need to be wrapped in try catch blocks. Most of the time is basically useless, except debugging, tracking, etc

So why not throw a runtimeException? It's not elegant and not very readable Make it your own exception. It derives from it, even if it is for no reason, except when throwing an exception

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>