Friday 15 July 2011

java - C# throw statement redundant? -


I have a code that looks like this (sorry for the Java bracket style): < Pre> class some class {public static zero doSomethingRisky (try {{SomeRiskyFunction ()}} hold (exception e) {throw e; }}} Class main clace {public zero call söshchensi () {try {SomeClass.doSomethingRisky}; } Catch (exception e) {end in the handles the exception (e); Basically, SomeClass will be a library and I want to design it so that all exceptions can be controlled by the calling program (which may or may not display any message about the exception .)

My question try / catch & amp; of doSomethingRisky () is about to use SomeClass . Is it redundant or is it necessary? I mean, if I leave it and the function faces an exception during the runtime, will it crash the program because there is no exception in that function, or is it still the collar ( CallSomethingRisky () ) where it is handled in a beautiful way?

The only question thanks to Java!

with try / hold Throw e; doSomethingRisky works in the same way: This stack-trace destroys information that probably is not what it is You wanted to, therefore, try / hold should be removed - this will be a bubble already - you expected as expected.

For information, if it was just , (instead of throw e; ) then it would be useless only, rather than destructive

No comments:

Post a Comment