• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exceptions  RSS feed

 
Vatsal Upadhyaya
Greenhorn
Posts: 18
Android Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the syntax for creating a customised exception....??
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Exception is just a class which extends the base Exception class. So to make your own, simply extend Exception (for a checked exception) or extend RuntimeException (if not checked). Of course you could extend any other Exception as well, if you wanted your Exception to be a specific form of IllegalArgumentException or whatever.
 
Mikasa Jaeger
Greenhorn
Posts: 24
Chrome Google App Engine Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An easy example of a simple exception:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!