I am learning CSharp. I have some doubts about handling exceptions. Trust me to improve my coding knowledge.
Suppose I build a code segment:
try {
SomeWork();
return success;
}
catch (someException ex)
{
throw new ExceptionDetails(ex);
return failure;
}
catch(AnotherException exp)
{
throw new ExceptionDetails(exp);
return failure;
}
finally
{
CleanUpStuff();
}
Questions:
(1) Is it possible to use the return statement after a throw (throwing exception)?
(2) Is throwing an exception an ugly practice? When do I just need to throw an exception? Do I need to use "throw" to send only a custom exception?
(3)
try
{
SomeWork();
}
catch(StringIndexOutOfBound ex)
{
throw;
}
Using an anonymous expression statement inside catch is good practice?
source
share