Use pseudovariable $exception rather than declaring an unused exception variable

Occasionally, I see catch blocks with unused exception variables.


Probably developer declare the variable so that they can inspect the exception while debugging, but, then forget to delete it. Since the unused variable results in a compiler warning (”The variable ‘ex’ is declared but never used”), its better to use pseudovariable $exception rather than declaring variable, if you need it just for debugging.


Visual studio also adds the variable to locals variables window by default.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s