Strategies for Error Handling in .NET Web Services

Posted by Jarrod on Stack Overflow See other posts from Stack Overflow or by Jarrod
Published on 2010-06-07T15:50:03Z Indexed on 2010/06/08 15:02 UTC
Read the original article Hit count: 326

I have a fairly substantial library of web services built in .NET that I use as a data model for our company web sites. In most .NET applications I use the Global ASAX file for profiling, logging, and creating bug reports for all exceptions thrown by the application.

Global ASAX isn't available for web services so I'm curious as to what other strategies people have come up with to work around this limitation. Currently I just do something along these lines:

<WebMethod()> _
Public Function MyServiceMethod(ByVal code As Integer) As String
    Try
        Return processCode(code)
    Catch ex As Exception
        CustomExHandler(ex) 'call a custom function every time to log exceptions
        Return errorObject
    End Try
End Function

Anybody have a better way of doing things besides calling a function inside the Catch?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about web-services