Home what are the effect of warning message in my program
Reply: 1

what are the effect of warning message in my program

A.Goutam
1#
A.Goutam Published in 2018-02-12 09:13:13Z

What is the effect of the warning message? Like my Program gives warning ex is declared but never used. I understand that I am not using ex in my program. But i want to know what exactly issue if I declared this type or variable and never used. Is this using memory or slow down my program or anything else.

    catch( Exception ex)
        {
        // Not using Ex in only declared to track when I debugging the code
        }
Steve
2#
Steve Reply to 2018-02-12 09:22:23Z

The problem is not the variable never used. This is just an informative warning just to allow you to remove the unused variable and have more clear code.

The real problem here is the fact that you have an EMPTY catch block. This means that you don't see any exception generated in the try block above. Thus you will never know of the presence of an error in your code. Never write an empty catch block even for debugging purposes. If you can't do anything to fix the 'exceptional' problem then do not catch it and let it bubble up the stack chain when some upper level catch block can do something to handle the error.

For example writing, in a log file, the whole information about the exception. Writing a log file of your exceptions is an effective way to track errors even when your code is no more running in a debug environment.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.330113 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO