I'm new to Resharper and I'm trying to understand why it seems to suggest:
catch (Exception) { }
for
catch { }
and
catch { }
for
catch (Exception) { }
I'm baffled.
I'm new to Resharper and I'm trying to understand why it seems to suggest:
catch (Exception) { }
for
catch { }
and
catch { }
for
catch (Exception) { }
I'm baffled.
It's just giving you alternatives to consider, which may spark some insight into improving your code. Just ignore the suggestion if it doesn't make sense.
Basically it's offering you a way of switching between the two alternatives, rather than making a concrete recommendation of which is better.
You can change what's offered under ReSharper / Options / Code Inspection / Inspection Severity - find the relevant option and change the priority between none, hint, suggestion, warning or error.
Because sometimes when tidying catch blocks you move to/from catch(Exception ex)
to catch(Exception)
to catch
and vice versa, depending on whether you're trying to purely filter, log/wrap, or swallow the exception. (See me requesting the same feature for CodeRush without being aware it even existed in R#)
EDIT: The link was previously labelled "Empty catch is bad" hence very correct downvotes!
Resharper does have another message that is more of a recommendation: it advises you not to catch the Exception
class.