Re: Exception handling and logging.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Roger Down" <roger-down@xxxxxxxxxxx> wrote in message
news:OFzglGQYFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
>I have a question regarding exception handling and logging.
>
> First let me explain the situation.
>
> I am creating a .NET library with functionality that I am giving to
> another team developer. This other developer does not want to be bother
> with all sorts of exceptions from me, but only wants "controlled" return
> codes/classes. This is because he wants to take action on whatever return
> code / class I return. Makes it easier.

This is the essential problem - the other developer wants to deal with .NET
code as if he was writing his app in C. Tell this other developer to deal
with exceptions because he really has no choice. Even if your module does
not throw exceptions, the entire framework does, as do other 3rd party
libraries.

>
> He want however me to log all exception to a common logging system.

You could do that, but then so can the main application. This really ought
to be handled in a global logging mechanism so that application itself can
set a logging policy. How is your module supposed to know where to log the
data to? If it can change, how is it configured? When should it be logged?
How is the user notified a problem occurred?There are many design questions
that ought to be addressed - a single component in the system usually does
not have enough context to make all the decisions.


> The other developer can now just check the return code from the
> SomeMethod() function.
>

Again, this is very bad practice with .NET code. It increases the liklihood
that an error condition will be missed or ignored.


.



Relevant Pages

  • Re: Exception handling?
    ... perhaps) issue when going exceptions. ... So for logging, there's, again, nothing to do if ... something about memory, or maybe disk". ... then the end user can fix it without a tech support call. ...
    (microsoft.public.vc.mfc)
  • Re: Error Handling
    ... exceptions are a reasonable approach to some input errors but that seems to ... indicating if the data is good or not but how does the error message get ... if the error message is "Invalid username and/or password", ... so logging just the username can also ...
    (comp.lang.java.programmer)
  • Re: Exception handling?
    ... perhaps) issue when going exceptions. ... So for logging, there's, again, nothing to do if ... exception-safety guarantees for any code snippet/function. ... but there are cases where in my more elaborate class based logging ...
    (microsoft.public.vc.mfc)
  • Re: Cannot open log for source {0} -- again
    ... >application log for security reasons. ... Even if you're only logging ... >exceptions, a malicious user of the web application could cause your event ... So when you said that writing to the event log from a web app wasn't a good ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: which kind of Exceptions to throw?
    ... As far as the distinction between the two go, ... generally considered to be that NotSupportedExcpetion is used in derived ... classes where the functionality isn't built into the base class. ... I'd recommend using custom exceptions when you need finely grained ...
    (microsoft.public.dotnet.general)