• Post Reply Bookmark Topic Watch Topic
  • New Topic

User Defined UnChecked Exception  RSS feed

 
Naresh Shaan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we create user definec unchecked exception,
let me knw!!!
thanks in advance!!!
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just inherit from RuntimeException or any of its sub-classes
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that this is controversial. I happen to fall in the camp that thinks there is a place for it. Read the exceptions chapter in Bruce Eckell's Thinking In Java (available online) for a balanced overview of the controversy.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
Be aware that this is controversial. I happen to fall in the camp that thinks there is a place for it. Read the exceptions chapter in Bruce Eckell's Thinking In Java (available online) for a balanced overview of the controversy.


If I could object just slightly. You will not find a balanced overview in this text. Simply, there is (at least) a third camp, who just "sit back and watch" and believe that both sides of the argument ride on a flawed premise and that failure to identify this flawed premise will result in what we observe today. This "camp" can also reliably predict the next movement (i.e. shift of reality) of both sides of the argument, and for this reason, proclaim a better understanding (e.g. using the scientific method is more plausible than ad hoc).
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my personnal rule of thumb: RuntimeException means BUG

=>

- only throw one when you are sure that you've encountered buggy situation you can't recover from
- do not catch a runtime but rather try to remove the cause


Now, in real life coding, there are plenty of cases when catching things like NullPointerException makes the code actualy more robust so the above rule is probably idealistic, but it's a good guide line anyway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!