User Defined Exceptions

Hi.

What exactly is the theme of User Defined Exceptions(in view of Exception hierarchy) ?

As said so far, User defined exceptions are useful for handling logical & functional errors. But when a exception is found in the throw block can we write the code there itself...instead of writing in catch block?

[328 byte] By [vikashindiaa] at [2007-11-27 7:42:02]
# 1

> What exactly is the theme of User Defined

> Exceptions(in view of Exception hierarchy) ?

Slightly blue, bordering on depressed-gray.

> As said so far, User defined exceptions are useful

> for handling logical & functional errors.

No. Errors are for errors. Exceptions are for exceptions. Important.

> But when a

> exception is found in the throw block can we write

> the code there itself...instead of writing in catch

> block?

Huh? Sort of an Early-Catch? No, unless you nest another try-catch inside that try block.

CeciNEstPasUnProgrammeura at 2007-7-12 19:22:46 > top of Java-index,Java Essentials,New To Java...
# 2

The basic idea of exception handling is: if you encounter a problem that you can't solve, toss it around as long as someone is actually able to do so.

The necessity for customized exceptions comes in pretty quick, as soon as your software gets more and more complex. The more complex your objects get, the more difficult it gets, to actually tell what went wrong with them.

Mongera at 2007-7-12 19:22:46 > top of Java-index,Java Essentials,New To Java...
# 3

While compiling a simple program sometime you may get exception, the java developers themselves make these exceptions. user defined exception is necessary for the programmers developing software using java, sometime it is necessary according to the user not to access something and here the benefit of user defined exception plays an important role. if you are a developer then you can restrict the user by providing the user defined exception.

chinmaysahooa at 2007-7-12 19:22:46 > top of Java-index,Java Essentials,New To Java...
# 4
Thanks a Kb.I understood ur reply for 3rd Q. But why to nest it.... Kindly explain me the logic...
vikashindiaa at 2007-7-12 19:22:46 > top of Java-index,Java Essentials,New To Java...