Ich dachte, dass es möglich ist, die Ausnahmebehandlung mit Attribut durchzuführen, anstatt "try ... catch" in jede einzelne Methode zu schreiben.Ausnahmebehandlung mit C# -Attribut
zum Beispiel jetzt, jedes meiner Methode wie folgt aussehen:
public void DoSomething()
{
try
{
// do something
}
catch (Exception ex)
{
// exception handling rules, always the same.
throw;
}
}
Ich möchte:
[HandleException]
public void DoSomething()
{
// do something
}
Ist es möglich?