J
john_c
FxCopy says this about catching general exceptions:
"You should not catch Exception or SystemException.
Catching generic exception types can hide run-time
problems from the library user, and can complicate
debugging. You should catch only those exceptions that
you can handle gracefully."
This is for a winform app but applies to asp.net also. There are some
code blocks you may know which exception may get thrown and others
that you are unsure. I guess FxCop is saying to just put in several
catches for specific exceptions. However, what if you guess wrong?
I currently write general exceptions into the Event Log. Why would
that not be a good way to go?
I'm not familiar with coding a robust try/catch/finally blocks. If
you put in the specific exception, say IOException, and your code
block happens to throw and argument exception, what then? If you
didn't do anything anywhere else, that goes straight up to the user
and crashes the app (winforms). What are the recommendations for
handling this?
Thanks,
John
"You should not catch Exception or SystemException.
Catching generic exception types can hide run-time
problems from the library user, and can complicate
debugging. You should catch only those exceptions that
you can handle gracefully."
This is for a winform app but applies to asp.net also. There are some
code blocks you may know which exception may get thrown and others
that you are unsure. I guess FxCop is saying to just put in several
catches for specific exceptions. However, what if you guess wrong?
I currently write general exceptions into the Event Log. Why would
that not be a good way to go?
I'm not familiar with coding a robust try/catch/finally blocks. If
you put in the specific exception, say IOException, and your code
block happens to throw and argument exception, what then? If you
didn't do anything anywhere else, that goes straight up to the user
and crashes the app (winforms). What are the recommendations for
handling this?
Thanks,
John