I want to log the running exception by the policy intercept. So I defined a custom call handler.
if there is exception after the getNext run it will log the exception, or it will return the value.
But it will throw the exception direct and not to log the exception.
I think it must have some misunderstood for me. Can anyone give me some advices?
Here is my source code:
public void Save(Product product)
throw new Exception("Exception Test.")
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
IMethodReturn methodReturn=getNext()(input, getNext);
// the exception will throw out direct and the follow code snippet will not be execute.
if (methodReturn.Exception != null)
LogWriter logWrite = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
LogEntry log = new LogEntry();
log.Title = Message;
log.Message = methodReturn.Exception.Message + methodReturn.Exception.InnerException.Message;
throw new Exception("The service issue, please wait or connect to the system administrator.");