Error Vs Exception


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."
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.