By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,168 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,168 IT Pros & Developers. It's quick & easy.

FxCop being a bit OTT?

P: n/a
Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception, and
since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that if
a user presses a button if for some reason my code fails the worst case
scenario for the user is either a usefull error message of a generic one
asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave
Jun 23 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
So... who's right here, FxCop or me?
FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #2

P: n/a
Thanks for that. Mostly I was just wondering if there was something I was
missing here. Seemed unlikely but you never know...

Dave

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OZ**************@TK2MSFTNGP06.phx.gbl...
"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
>So... who's right here, FxCop or me?

FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #3

P: n/a
If you read the documentation for this error, you'll find that they
already make an exception for global exception handling and logging
situations much like you are describing.

Jesse

* Dave wrote, On 23-6-2007 14:07:
Thanks for that. Mostly I was just wondering if there was something I was
missing here. Seemed unlikely but you never know...

Dave

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OZ**************@TK2MSFTNGP06.phx.gbl...
>"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
>>So... who's right here, FxCop or me?
FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #4

P: n/a
Dave wrote:
Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception, and
since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that if
a user presses a button if for some reason my code fails the worst case
scenario for the user is either a usefull error message of a generic one
asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave
Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure
that you know what it's founded on and that you know the alternatives.

In this case there is no reason to catch all exceptions in order to
shelter the users from error messages. Just use the
Application.ThreadException event, which fires whenever a thread ends
with an unhandled exception.

--
Göran Andersson
_____
http://www.guffa.com
Jun 23 '07 #5

P: n/a
Thanks for that but the majority of the errors will be in background threads
which I don't want to terminate on an error (need to free resources, send
error messages over the network, etc). Given my understanding of
Application.ThreadException and Applicatoin.UnhandledException I have to
provide the catch all handlers in each thread individually to be able to do
this.

Dave
"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure that
you know what it's founded on and that you know the alternatives.

In this case there is no reason to catch all exceptions in order to
shelter the users from error messages. Just use the
Application.ThreadException event, which fires whenever a thread ends with
an unhandled exception.

--
Göran Andersson
_____
http://www.guffa.com

Jun 23 '07 #6

P: n/a


"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
Dave wrote:
>Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception,
and since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that
if a user presses a button if for some reason my code fails the worst
case scenario for the user is either a usefull error message of a generic
one asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave

Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure that
you know what it's founded on and that you know the alternatives.
The problem is that the default settings give so much information, that the
average user (read me) is going to ignore them all. Things like getting a
warning every time you use a string litereal.
Jun 24 '07 #7

P: n/a
JR
Sort by error and ignore those you wish to ignore.

JR

"Ian Semmel" <an****@rocketcomp.com.au???
??????:e7**************@TK2MSFTNGP04.phx.gbl...
>

"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
>Dave wrote:
>>Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception,
and since in my (apparent) foolishness I'm catching all errors in my
user interface I've got a fair few of these in my code. I'm doing this
so that if a user presses a button if for some reason my code fails the
worst case scenario for the user is either a usefull error message of a
generic one asking them to send in an error log file rather than having
the whole application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave

Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure
that you know what it's founded on and that you know the alternatives.

The problem is that the default settings give so much information, that
the average user (read me) is going to ignore them all. Things like
getting a warning every time you use a string litereal.


Jun 25 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.