Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The variable 'MyException' is declared but never used

I need to clear this warning :

try {     doSomething() } catch (AmbiguousMatchException MyException) {     doSomethingElse() } 

The complier is telling me :

The variable 'MyException' is declared but never used

How can I fix this.

like image 651
Wassim AZIRAR Avatar asked Jun 23 '11 14:06

Wassim AZIRAR


1 Answers

  1. You can remove it like this:

    try {     doSomething() } catch (AmbiguousMatchException) {     doSomethingElse() } 
  2. Use warning disable like this:

    try {     doSomething() } #pragma warning disable 0168 catch (AmbiguousMatchException exception) #pragma warning restore 0168 {     doSomethingElse() } 

Other familiar warning disable

#pragma warning disable 0168 // variable declared but not used. #pragma warning disable 0219 // variable assigned but not used. #pragma warning disable 0414 // private field assigned but not used. 
like image 90
Jalal Said Avatar answered Oct 10 '22 22:10

Jalal Said