The situation is this. I have an asp.net webservice application...say a page called api.asmx
In the code behind I have several methods, for example:
[WebMethod(Description="Method1")]
public int GetSomething(int num1, int num2){
try{
return SomeObject.DatabaseCall.DoSomething(num1, num2);
}
catch(Exception ex){
object[] pars = new object[] { num1, num2 };
LogError("GetSomething", pars, ex);
}
}
[WebMethod(Description="Method2")]
public int GetSomething2(string w, string j, int f){
try{
return AnotherObject.DoSomething(w, j, f);
}
catch(Exception ex){
object[] pars = new object[] { w, j, f };
LogError("GetSomething2", pars, ex);
}
}
Of course these are just two simple examples where, if an exception is thrown, I can log the method call and parameters passed in.
Is there another way to do this? Is there some way that I can extract the method being called and/or the parameters. I guess I'm hoping someone will tell me that I can just have some kind of function like:
LogError(ex);
And within that function I can access some Server or Environment variables that will expose the method being called. Maybe something like CurrentContext.WebServiceCall.Magic property... Do I need to wrap all my calls in a try/catch and then type out the method name and parameters, or is there another way to access this information.
Hopefully this question ins't too stupid.