...

/

Errors Handling and Types of Errors

Errors Handling and Types of Errors

Learn about error handling and different types of errors.

Error Handling

Handling errors or exceptional conditions is a key part of any programming language. Even small scripts and programs should ideally be written with the ability to catch exceptions and handle them gracefully in an expected manner. In this chapter, we are going to delve deeper into types of errors and how to handle them. We will learn to throw, catch, and create custom errors.

Types of Errors

Generally, there are 3 types of errors: syntax, runtime, and logical errors. Let’s look into each of these errors one at a time.

Syntax errors

In any language , the arrangement of words and phrases to create well-formed sentences is called syntax. In Computer Science, however, syntax is a structure of statements. Two important takeaway words from these definitions are “well-formed” and “structure”.

So, in any programming language, a syntax error is usually observed when the parser detects an incorrect statement or finds a programming construct like a ...