i want to use AOP to handle my error exception in Console application. ( it is not MVC i used attribute vase programing to handle errors in mvc but this is console app) My code below: ( if error occurs ,it should throw an error yo my attribute side code )
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class HandleError : Attribute
{
public HandleError(string description)
{
try
{
this.Description = description;
}
catch (Exception)
{
throw;
}
}
public string Description { get; set; }
}
this will call from my method :
[HandleError("Error occurs here")]
public static void MyMethod(string data)
{
throw new Exception();
Actually; i want to use AOP to handle exceptions inside my method. i have to call attributes if it error occurs. But How? ( please don't offer postsharp, it needs money. but i am open for opensource also)By the way; why it is not easy ,i don't understand.
Aucun commentaire:
Enregistrer un commentaire