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.

Author: Brian Cline

Brian is a programmer living in Niagara Falls with ten years of development experience. He is passionate about automation, business process re-engineering, and gamification. For the last six years or so, he has been working with Salesforce and JavaScript.

Related Posts

Sharing is Caring