954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Exception handling in vb.net

Is exception handling useful in
compile time errors
logical errors
and even runtime errors?

sharathg.satya
Posting Whiz in Training
264 posts since Oct 2010
Reputation Points: 0
Solved Threads: 5
 

Exception handling is not useful for compile-time errors.

It should NOT be used for logic errors.

It should be used for runtime errors where something is completely out of your control.

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

Exception handling is not useful for compile-time errors.

It should NOT be used for logic errors.

It should be used for runtime errors where something is completely out of your control.


we can use even for logical errors...isnt it?
suppose we have
dim a as integer=10
dim b as integer=0
dim c as integer
c=a/b
as this is logical error we use exception handlers to handle this
which means that we are using even to handle logical errors.

sharathg.satya
Posting Whiz in Training
264 posts since Oct 2010
Reputation Points: 0
Solved Threads: 5
 

It would be MUCH better to test for zero and not divide by it than to let an exception occur. If you can predict it or prevent it, do so with code.

Exception processing is costly if your program is to continue running (doesn't just exit on the first exception).

A lot of coding is about control. The first step of maintaining control is ensure you have it in the first place :)

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

It would be MUCH better to test for zero and not divide by it than to let an exception occur. If you can predict it or prevent it, do so with code.

Exception processing is costly if your program is to continue running (doesn't just exit on the first exception).

A lot of coding is about control. The first step of maintaining control is ensure you have it in the first place :)


ok thanks for the reply..
And finally exception handling process is a costly one ...
Is this the final conclusion why u asked me to test for zero rather than dividing it?

sharathg.satya
Posting Whiz in Training
264 posts since Oct 2010
Reputation Points: 0
Solved Threads: 5
 

>>Is this the final conclusion why u asked me to test for zero rather than dividing it?
.i think so As well.
reason: Running the Try/Catch/etc., it sends the p.c. into shock Not just your tiny little app.

Hope this helps.:)

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

>>Is this the final conclusion why u asked me to test for zero rather than dividing it? .i think so As well. reason: Running the Try/Catch/etc., it sends the p.c. into shock Not just your tiny little app.

Hope this helps.:)


yes thanks
the problem is solved..

sharathg.satya
Posting Whiz in Training
264 posts since Oct 2010
Reputation Points: 0
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You