我必须为 Enteprise Library 4.1 实现一个 IExceptionHandler。在我的特殊情况下,我想用它来记录 Fogbugz 的异常,但内部细节不是我要问的。我需要的是如何 - 最佳实践 - 实现它,如何获取 app.config 或 web.config 的配置。等等
到目前为止,我有代码:
public class LcpFogbugzExceptionHandler : IExceptionHandler {
/// <summary>
/// Initializes a new instance of the <see cref="LcpFogbugzExceptionHandler"/> class.
/// </summary>
public LcpFogbugzExceptionHandler() {
// <param name="ignore">The ignore.</param>
//NameValueCollection ignore
}
/// <summary>
/// Initializes a new instance of the <see cref="T:LcpFogbugzExceptionHandler"/> class.
/// </summary>
/// <param name="ignore">The ignore.</param>
public LcpFogbugzExceptionHandler(NameValueCollection ignore) {
}
/// <summary>
/// Handles the exception.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="handlingInstanceId">The handling instance id.</param>
/// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Convert.ToBoolean(System.String)")]
public Exception HandleException(Exception exception, Guid handlingInstanceId) {
// Perform processing here. The exception returned will be passed to the next
// exception handler in the chain.
return exception;
}
}