Strategies for Error Handling in .NET Web Services
- by Jarrod
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?