Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv32420
Modified Files:
ObjectUtils.cs ReflectionUtils.cs
Log Message:
ContextRegistry.GetContext() / WebApplicationContext.Current should print a detailed error [SPRNET-475].
Index: ReflectionUtils.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/ReflectionUtils.cs,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** ReflectionUtils.cs 20 Sep 2007 12:31:01 -0000 1.50
--- ReflectionUtils.cs 5 Oct 2007 17:06:01 -0000 1.51
***************
*** 991,994 ****
--- 991,1017 ----
}
+ /// <summary>
+ /// Returns the explicit <see cref="System.Exception"/> that is the root cause of an exception.
+ /// </summary>
+ /// <remarks>
+ /// If the InnerException property of the current exception is a null reference
+ /// or a <see cref="System.NullReferenceException"/>, returns the current exception.
+ /// </remarks>
+ /// <param name="ex">The last exception thrown.</param>
+ /// <returns>
+ /// The first explicit exception thrown in a chain of exceptions.
+ /// </returns>
+ public static Exception GetExplicitBaseException(Exception ex)
+ {
+ Exception innerEx = ex.InnerException;
+ while (innerEx != null &&
+ !(innerEx is NullReferenceException))
+ {
+ ex = innerEx;
+ innerEx = innerEx.InnerException;
+ }
+ return ex;
+ }
+
/// <summary>
/// Copies all fields from one object to another.
Index: ObjectUtils.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/ObjectUtils.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ObjectUtils.cs 7 Sep 2007 04:46:39 -0000 1.6
--- ObjectUtils.cs 5 Oct 2007 17:06:01 -0000 1.7
***************
*** 211,219 ****
return constructor.Invoke(arguments);
}
! catch (TargetInvocationException ex)
{
throw new FatalReflectionException(
! string.Format(
! CultureInfo.InvariantCulture, "Failed instantiating type [{0}].", constructor.DeclaringType), ex.InnerException);
}
}
--- 211,223 ----
return constructor.Invoke(arguments);
}
! catch (Exception ex)
{
+ Type ctorType = constructor.DeclaringType;
throw new FatalReflectionException(
! string.Format(
! CultureInfo.InvariantCulture,
! "Cannot instantiate Type [{0}] using ctor [{1}] : '{2}'",
! constructor.DeclaringType, constructor, ex.Message),
! ex);
}
}
|