What is the queue to the ExceptionCallHandler?

Topics: Exception Handling Application Block, Policy Injection Application Block
Jun 28, 2011 at 9:58 AM


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:

[ExceptionLogCallhandler("Save Product",1)]

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.");          




                      return methodReturn;            






Jun 28, 2011 at 10:55 AM
Edited Jun 28, 2011 at 11:59 AM


The code you posted will log the error and return the value. The exception will not happen inside the call handler but to the calling method.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.

Jun 29, 2011 at 9:02 AM

Thank you.