• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

User Defined UnChecked Exception

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we create user definec unchecked exception,
let me knw!!!
thanks in advance!!!
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just inherit from RuntimeException or any of its sub-classes
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Get off me! Here, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic