Let say my application code is structure is layer.
For eg
First Layer is client service layer.
Second is validation Layer
Third is custom Business Logic Layer.
Forth is Core Business Logic Layer.
Fifth is ORM Layer.
We want that at any point/level of application code if we see that the request made by user cannot be provisioned (may be due to lack of data required or any other application logic constrain) And we want to throw error which should not be caught by any other layer except the top layer, so that the error msg can be shown to User properly.
To achieve this i was thinking to create a new class which extends Error
.
So that it remain unchecked and can skip any try catch block
which catches Exception.
Does it looks like a good strategy , is there a bttern pattern as my solution goes against the javadoc ?
The Javadoc explains it well:
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.