• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

Error Vs Exception

Hi

Someone asked me the difference between the two. I got one point, please check whether it is fine or not and what are the other points that elaborates the difference between the two.

"An error is a condition which is not catched whereas an exception is a condition which can be catched."
0
KaranGupta
Asked:
KaranGupta
3 Solutions
 
tomcahillCommented:
You're correct.

An exception is just that, something that is outside the parameters.

Where as an error is a mistake, they can be syntax errors, logic errors, etc...

An exception can occur because of an error, or it can be thrown intentionally.
0
 
sameer_goyalCommented:
Simply, put

an error is something which is wrong, either syntactically or logically or a wrong implementation of a requirement.

For eg

1. A syntax error is using == to assign a value to a paramete
2. A logical error is to use subtraction in place of addition
3. A wrong implementation error is that yields to wrong or unexpected results

However, an exception is that 'condition' which occurs in a certain situation. For eg, simply put,

X = y/a

This code is prone to an exception in case a becomes 0. But only in case a becomes 0. Till the time, a is not 0, the code will work fine and yield expected results.

I hope that is of some use.

cheers
Sam
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now