Tuesday 28 February 2023

Exception & Different types of Exceptions

An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.
 
There are many different types of exceptions, each of which represents a specific error condition that can occur during the execution of a program. Here are some common types of exceptions :

DivideByZeroException: This exception is thrown when attempting to divide by zero, as discussed earlier.

FormatException: This exception is thrown when a format string is not valid or a value cannot be converted to the expected format.

ArgumentNullException: This exception is thrown when a method or constructor is called with a null argument that is not allowed.

ArgumentException: This exception is thrown when an argument to a method or constructor is invalid or out of range.

InvalidOperationException: This exception is thrown when an operation is invalid for the current state of an object.

NotSupportedException: This exception is thrown when an operation is not supported.

OverflowException: This exception is thrown when an arithmetic operation results in an overflow or underflow condition.

OutOfMemoryException: This exception is thrown when there is not enough memory to allocate an object.

StackOverflowException: This exception is thrown when the stack overflows due to too many nested function calls.

TimeoutException: This exception is thrown when an operation times out before completing.

IOException: This exception is thrown when an input/output operation fails.

NullReferenceException: This exception is thrown when an attempt is made to de-reference a null object reference.

IndexOutOfRangeException: This exception is thrown when an attempt is made to access an array or collection with an index that is out of range.

FileNotFoundException: This exception is thrown when a file that is expected to exist cannot be found.

FormatException: This exception is thrown when an input value cannot be parsed to the expected format.
 

0 comments:

Post a Comment

Please do not enter any spam link in the message box.