I have a block of code inside a try catch block (c#). The block of code can throw two exceptions (ArgumentException/NullRefernceException).
try
{
//Code
}
catch(NullRefernceException Ex)
{
//Error Handling Code
}
catch(ArgumentException Ex)
{
//Error Handling code
}
The error handling code is the same in both the Exceptions. So can i keep the error handling code in ArgumentException catch block and upon NullRefernceException can i throw ArgumentException since i have a catch block follwing it. Not sure whether it will work and does it have any harm on the performance and whether it is a good programming practice.
Am i left with no option but either to have the same code in both the catch blocks or to have a separate method holding the error handling code?
I don't want to keep the error handling code in a separate method and invoke.