try..catch Usage – Unused Variable Warning

Sharing is Caring

Elminating the unused variable warning for a declaration in the catch block is very easy because you don’t need to assign to a variable.

See the below code for an example.


try {
doSomething();
}catch (Exception) {
logError();
}

Note: you should always log an exception if it isn’t expected. For example, for any IO Related exceptions you should probably log these.

Hope this helps.

Sharing is Caring

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.