I am Studying about Exceptions At W3schools At this Link, inside the link just before the heading:
“Re-throwing Exceptions”
there is a sentence that say:
“If the exception thrown were of the class customException and there
were no customException catch, only the base exception catch, the
exception would be handled there.”
If can someone please give me an example for this sentence i will be very thankful.
Say you have a custom exception defined as
class CustomException extends Exception.Now somewhere in your code:
So what it means is that because CustomException is a subclass of Exception, as long as you catch the Exception type of the superclass without a catch block for the more specific sub class type, it will still be caught