Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Exceptions
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv6782/Exceptions
Modified Files:
ExceptionHandlerAdvice.cs LogExceptionHandler.cs
ReturnValueExceptionHandler.cs TranslationExceptionHandler.cs
Removed Files:
AbstractExceptionHandler.cs IExceptionHandler.cs
Log Message:
make exception handling of expressions in exception advice more robuts
remove ITargetTypeAware - requires more changes to internal AOP infrastructure - not worth the effort for this convenience
removed files that were moved to another namespace (AbstractExceptionHander/IExceptionHandler)
Index: ReturnValueExceptionHandler.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Exceptions/ReturnValueExceptionHandler.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ReturnValueExceptionHandler.cs 2 Oct 2007 21:56:53 -0000 1.2
--- ReturnValueExceptionHandler.cs 10 Oct 2007 18:07:46 -0000 1.3
***************
*** 19,23 ****
--- 19,25 ----
#endregion
+ using System;
using System.Collections;
+ using Common.Logging;
using Spring.Expressions;
***************
*** 55,60 ****
public override object HandleException(IDictionary callContextDictionary)
{
! IExpression expression = Expression.Parse(ActionExpressionText);
! return expression.GetValue(null, callContextDictionary);
}
}
--- 57,71 ----
public override object HandleException(IDictionary callContextDictionary)
{
! object returnVal = null;
! try
! {
! IExpression expression = Expression.Parse(ActionExpressionText);
! returnVal = expression.GetValue(null, callContextDictionary);
! }
! catch (Exception e)
! {
! log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
! }
! return returnVal;
}
}
Index: TranslationExceptionHandler.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Exceptions/TranslationExceptionHandler.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TranslationExceptionHandler.cs 2 Oct 2007 21:56:53 -0000 1.2
--- TranslationExceptionHandler.cs 10 Oct 2007 18:07:46 -0000 1.3
***************
*** 21,24 ****
--- 21,25 ----
using System;
using System.Collections;
+ using Common.Logging;
using Spring.Expressions;
***************
*** 55,60 ****
public override object HandleException(IDictionary callContextDictionary)
{
! IExpression expression = Expression.Parse(ActionExpressionText);
! object o = expression.GetValue(null, callContextDictionary);
Exception translatedException = o as Exception;
if (translatedException != null)
--- 56,68 ----
public override object HandleException(IDictionary callContextDictionary)
{
! object o = null;
! try {
! IExpression expression = Expression.Parse(ActionExpressionText);
! o = expression.GetValue(null, callContextDictionary);
! }
! catch (Exception e)
! {
! log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
! }
Exception translatedException = o as Exception;
if (translatedException != null)
Index: ExceptionHandlerAdvice.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ExceptionHandlerAdvice.cs 10 Oct 2007 07:38:17 -0000 1.7
--- ExceptionHandlerAdvice.cs 10 Oct 2007 18:07:46 -0000 1.8
***************
*** 156,159 ****
--- 156,164 ----
object returnVal = InvokeHandlers(ex, invocation);
+ if (returnVal == null)
+ {
+ return null;
+ }
+
// if only logged
if (returnVal.Equals("logged"))
--- AbstractExceptionHandler.cs DELETED ---
--- IExceptionHandler.cs DELETED ---
Index: LogExceptionHandler.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LogExceptionHandler.cs 2 Oct 2007 21:56:53 -0000 1.4
--- LogExceptionHandler.cs 10 Oct 2007 18:07:46 -0000 1.5
***************
*** 19,22 ****
--- 19,23 ----
#endregion
+ using System;
using System.Collections;
using Common.Logging;
***************
*** 73,80 ****
ILog log = LogManager.GetLogger(logName);
callContextDictionary.Add("log", log);
! IExpression expression = Expression.Parse(ActionExpressionText);
! expression.GetValue(null, callContextDictionary);
!
! return "logged";
}
}
--- 74,87 ----
ILog log = LogManager.GetLogger(logName);
callContextDictionary.Add("log", log);
! try
! {
! IExpression expression = Expression.Parse(ActionExpressionText);
! expression.GetValue(null, callContextDictionary);
! }
! catch (Exception e)
! {
! log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
! }
! return "logged";
}
}
|