Making your own exception?

  • Thread starter Thread starter Jarod_24
  • Start date Start date
J

Jarod_24

Throw new Excption ("bla, bla, bla")
....
Catch E as Exception
If E.Message.Equals("bla, bla, bla") Then ...


Mostly i just use the standard "Exception"-object whenever i throw an
exception, but it would be nice sometimes to make you own
"MyException"-object that you can then easier Catch. using:

Catch Exp as MyException
....

Whenever i use the standard exception-object i check to see if the E.Message
equals the one i made, but since this isn't a very good way of coding, so
how do i make my own Exception-object. Do i need to make a new class that
inherits/implements from the Exception.class, or is there a way to do it
without starting making a exception-class for each object you want a
specialized exception for. Someting you do when you trow the exception for
example?
 
Back
Top