exception subclass for try-catch block [Answered]
I want to subclass Exceptions to create a class that can be inserted into a catch() parameter to detect errors.
(Say for example I want an exception class that can detect if a triangle is valid)
I looked through the microsoft libraries' source code for some inkling of a conditional that logically allows for something like catch(DivideByZeroException) but could not find anything that made sense to me.
I'm dumbfounded. Without conditionals, how else does catch() detect which exception is being thrown?
5 Replies
Ok but what if my condition doesn't normally throw an exception
Like the compiler won't normally throw an exception for triangle of sides a,b,c if a+b<c
Do I need to manually throw an exception each time?
of course, if its not an exception that the language or libraries you are using are going to be throwing for you, you will have to throw them yourself were applicable.
I see
I have completely misunderstood the flow of the throw-catch process
thanks!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
✅ This post has been marked as answered!