Codementor Events

Error and Exception

Published Aug 06, 2020Last updated Aug 12, 2020
Error and Exception

Error and Exception

There are two things which we consider mostly while working on any project i.e. error and exception. I will cover the main difference between exception and error which is mostly confused with each other.

Let’s first clear the difference between error and exception.

Error is nothing but a problem which arises due to faulty or poor coding or external issues rather than application itself, so for desired output error must be handled properly by removing all the possible bugs.

For example: NoClassDefFoundError, OutOfMemoryError (Hardware issue), etc.

Exception is an acceptable condition which drastically alters the flow of the code, so exceptions are must to handle; try and catch blocks are used to handle the exceptions.

For example: If you have written a code for reading a file from D drive (consider any folder). The code is working fine till now unless anyone deletes that particular file, it will definitely disrupt the flow of the code. Considering the condition which is reasonable, as anyone can delete the file who has access to that particular file so to solve the issue an exception FileNotFoundException must be caught.

Let us take an example of hierarchy using a popular language known as JAVA

Exception Handling.PNG

I hope this post will be of little help for you to understand the concept error and exception.
This post just consisted of theoretical aspects of Exception Handling and not the practical one. We will be taking a deep dive in the next post where we will be decoding error and exception practically.

Discover and read more posts from Pritish Deshpande
get started
post commentsBe the first to share your opinion
Show more replies