I'm pretty new to .net so my knowledge is pretty limited in many areas.
I'm creating a website at the moment, and have created a few static methods to help me out - here's an example:
public static void ThrowNull<T>(this T obj, string param) where T : class { if (param.IsNullOrEmpty()) Throw<ArgumentException>("Undefined param!"); if (obj.IsNull()) Throw<ArgumentNullException>(param); } I use it as a parameter guard in other methods, calling like this: myVar.ThrowNull("myVar");
The Throw method referred to above looks like this:
static void Throw<E>(string message) where E : Exception { throw Activator.CreateInstance(typeof(E), message) as E; } This all works great for testing but I want to be able to log details that occur from users. How do I get stack trace information from this point?
Any advice appreciated.