Alex Rivera | Logout

Why does resharper say 'Catch clause with single 'throw' statement is redundant'?

Asked 2009-06-19T17:55:10.097
20

I thought throwing an exception is good practice to let it bubble back up to the UI or somewhere where you log the exception and notify the user about it.

Why does resharper say it is redundant?

try
{
    File.Open("FileNotFound.txt", FileMode.Open);
}
catch
{
    throw;
}
Edit
Report

1 Answer

17

Because the above statement has the same behavior as if it were not there. Same as writing:

File.Open("FileNotFound.txt", FileMode.Open);
answered 2009-06-19T17:56:28.003

Your Answer