Uploaded on Mar 2, 2023
PPT on Error Handling
What is Error Handling?
What is Error Handling?
Introduction
The tasks of the Error Handling process are to detect each
error, report it to the user, and then make some recovery
strategy and implement them to handle the error. During this
whole process processing time of the program should not be
slow.
Source: www.geeksforgeeks.org
Functions of Error Handler
● Error Detection
● Error Report
● Error Recovery
Source: www.geeksforgeeks.org
Error Detection
Errors in the program should be detected and reported by the
parser. Whenever an error occurs, the parser can handle it and
continue to parse the rest of the input.
Source: www.geeksforgeeks.org
Error Detection Cont.
Although the parser is mostly responsible for checking for
errors, errors may occur at various stages of the compilation
process.
Source: www.geeksforgeeks.org
Logic errors
Logic errors occur when programs operate incorrectly but do
not terminate abnormally (or crash). Unexpected or undesired
outputs or other behaviour may result from a logic error, even if
it is not immediately recognized as such.
Source: www.geeksforgeeks.org
Run-time errors
A run-time error is an error that takes place during the
execution of a program and usually happens because of
adverse system parameters or invalid input data. The lack of
sufficient memory to run an application or a memory conflict
with another program and logical error is an example of this.
Source: www.geeksforgeeks.org
Compile-time errors
Compile-time errors rise at compile-time, before the execution
of the program. Syntax error or missing file reference that
prevents the program from successfully compiling is an
example of this.
Source: www.geeksforgeeks.org
Classification of Compile-time errors
1. Lexical : This includes misspellings of identifiers,
keywords or operators
2. Syntactical : a missing semicolon or unbalanced
parenthesis
3. Semantical : incompatible value assignment or type
mismatches between operator and operand
4. Logical : code not reachable, infinite loop.
Source: www.geeksforgeeks.org
Finding error or reporting an error
1. Goal detection of an error as soon as possible without
further consuming unnecessary input
2. How: detect an error as soon as the prefix of the input
does not match a prefix of any string in the language.
Source: www.geeksforgeeks.org
Error Recovery
The basic requirement for the compiler is to simply stop and
issue a message, and cease compilation. There are some
common recovery methods that are as follows.
Source: www.geeksforgeeks.org
Comments