18 using System.Reflection;
20 using System.Collections.Generic;
29 private readonly List<IExceptionInterpreter> _interpreters;
34 public static readonly Lazy<StackExceptionInterpreter>
Instance =
new Lazy<StackExceptionInterpreter>(
48 _interpreters = interpreters.OrderBy(x => x.Order).ToList();
54 public IEnumerable<IExceptionInterpreter>
Interpreters => _interpreters;
63 return _interpreters.Any(interpreter => interpreter.CanInterpret(exception));
77 if (exception ==
null)
82 foreach (var interpreter
in _interpreters)
86 if (interpreter.CanInterpret(exception))
89 return interpreter.Interpret(exception, innerInterpreter ??
this);
108 return string.Join(
" ", InnersAndSelf(exception).Select(e => e.Message));
119 from assembly in assemblies
120 from type in assembly.GetTypes()
122 where type.IsPublic && !type.IsAbstract
126 where type.FullName !=
null && !type.FullName.StartsWith(
"Castle.Proxies.ObjectProxy")
128 where type.GetConstructor(
new Type[0]) !=
null
130 orderby type.FullName
135 foreach (var interpreter
in stackExceptionInterpreter.Interpreters)
140 return stackExceptionInterpreter;
143 private IEnumerable<Exception> InnersAndSelf(Exception exception)
145 yield
return exception;
146 while (exception.InnerException !=
null)
148 exception = exception.InnerException;
149 yield
return exception;