Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: Tracing extension methods should interpret HttpResponseException [1201]

$
0
0
The ITraceWriter extension methods trace all exceptions at TraceLevel.Error, which is often incorrect when the exception is HttpResponseException (which could hold warning or success codes). Even a simple NotFound or BadRequest warning gets traced as an error, causing false alarms about the health of the app. WebAPI itself throws HttpResponseException for situations like BadRequest. Customer apps could even return OK via HttpResponseException, making an error level trace particularly misleading.

Issue http://aspnetwebstack.codeplex.com/workitem/949 addressed this for the SystemDiagnosticsTraceWriter by reversing what the ITraceWriter extension methods had done, but that is an incomplete solution -- all other trace writers will need to do this same special handling.

The appropriate location for the fix is in the 'catch' clauses in ITraceWriterExtensions.TraceBeginEnd, TraceBeginEndAsync and TraceBeginEndAsyncCore.

The code from SystemDiagnosticsTraceWriter.TranslateHttpResponseException should be moved into a helper method in ITraceWriterExtensions and invoked from those 'catch' clauses. That code already (correctly) maps the HttpResponseException's status code to trace level and (correctly) expands any HttpError into meaningful model binding or exception messages. The code only has to move -- it does not need to change.

After this fix, all ITraceWriter implementations will receive the correct and more informative trace records for HttpResponseException with no need to special case it.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>