Ok ich habe mir das ganze jetzt angeschaut. Und zwar habe ich folgendes Beispiel angeschaut:
[DatabaseExceptionWrapper]
private void Test()
{
throw new Exception("Hallo Welt");
}
}
[Serializable]
public class DatabaseExceptionWrapper : OnExceptionAspect
{
public override void OnException(MethodExecutionArgs args)
{
string msg = string.Format("{0} had an error @ {1}: {2}\n{3}",
args.Method.Name, DateTime.Now,
args.Exception.Message, args.Exception.StackTrace);
Console.WriteLine(args);
throw new Exception("There was a problem");
}
}
Nun macht das aber auch nicht das was ich will. Weil wenn ich jetzt auch das
throw new Exception("There was a problem");
auskommentiere schmeißt das ganze trotzdem noch eine Exception. Und so ein resultat erreiche ich auch einfacher. Indem ich folgendes mache:
class UnhandledException
{
public static void AddHandler()
{
System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
}
private static void UnhandledExceptionHandler(System.Object sender, UnhandledExceptionEventArgs args)
{
H.uerr.WriteError((Exception)args.ExceptionObject, "Nothing");
if (!System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
Also gibt es nichts um Exceptions zu notieren und anschließend einfach aufzufangen ohne, dass diese geschmissen werden?