I would like to handle errors with (unchecked) exceptions. I heared that for each kind of exception I should create a subclass of either Error or RuntimeException.
What’s the difference?
I would like to handle errors with (unchecked) exceptions. I heared that for each
Share
Errorsshould identify programmatically unrecoverable problems (e.g. out of memory).Exceptionsshould identify programmatically recoverable problems which are caused by unexpected conditions outside control of code (e.g. database down).RuntimeExceptionsshould identify programmatically recoverable problems which are caused by faults in code flow (read: developer’s faults such as null pointer, illegal argument, etc).In your case you want to inherit from
RuntimeException.