chrispepper1989
chrispepper1989

Reputation: 2190

Refactor to rethrow swallowed exceptions

I am working on a codebase that does an awful lot of exception swallowing, in most cases like this:

catch (Exception ex)
{
    MessageBox.Show(ex.Message, "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

Is there a quick way, e.g. with resharper to add a throw to all of these? or at least break on message box show? Because all i get is a generic error message with no indication of where it is in the code..

I tried Resharper search with pattern but the minute I add "catch" it says the search is ambiguous

Upvotes: 1

Views: 135

Answers (1)

John Saunders
John Saunders

Reputation: 161783

ReSharper pattern search is great, but it is very syntax-driven. To match your catch, you'll need to include the try in the search.

Upvotes: 1

Related Questions