| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Reflection; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | using CoreWCF.Dispatcher; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Diagnostics |
| | | 10 | | { |
| | | 11 | | // TODO: Work out how TraceUtility fits in with all the other exception and tracing classes |
| | | 12 | | internal static class TraceUtility |
| | | 13 | | { |
| | | 14 | | internal static Exception ThrowHelperError(Exception exception, Message message) |
| | | 15 | | { |
| | | 16 | | // If the message is closed, we won't get an activity |
| | | 17 | | //Guid activityId = TraceUtility.ExtractActivityId(message); |
| | | 18 | | //if (DiagnosticUtility.ShouldTraceError) |
| | | 19 | | //{ |
| | | 20 | | // DiagnosticUtility.DiagnosticTrace.TraceEvent(TraceEventType.Error, TraceCode.ThrowingException, Genera |
| | | 21 | | // TraceSR.Format(TraceSR.ThrowingException), null, exception, activityId, null); |
| | | 22 | | //} |
| | 15 | 23 | | return exception; |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | internal static Exception ThrowHelperError(Exception exception, Guid activityId, object source) |
| | | 27 | | { |
| | | 28 | | //if (DiagnosticUtility.ShouldTraceError) |
| | | 29 | | //{ |
| | | 30 | | // DiagnosticUtility.DiagnosticTrace.TraceEvent(TraceEventType.Error, TraceCode.ThrowingException, Genera |
| | | 31 | | // TraceSR.Format(TraceSR.ThrowingException), null, exception, activityId, source); |
| | | 32 | | //} |
| | 0 | 33 | | return exception; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | internal static void TraceUserCodeException(Exception e, MethodInfo method) |
| | | 37 | | { |
| | | 38 | | //if (DiagnosticUtility.ShouldTraceWarning) |
| | | 39 | | //{ |
| | | 40 | | // StringTraceRecord record = new StringTraceRecord("Comment", |
| | | 41 | | // SR.Format(SR.SFxUserCodeThrewException, method.DeclaringType.FullName, method.Name)); |
| | | 42 | | // DiagnosticUtility.DiagnosticTrace.TraceEvent(TraceEventType.Warning, |
| | | 43 | | // TraceCode.UnhandledExceptionInUserOperation, GenerateMsdnTraceCode(TraceCode.UnhandledExceptionInU |
| | | 44 | | // SR.Format(SR.TraceCodeUnhandledExceptionInUserOperation, method.DeclaringType.FullName, method.Nam |
| | | 45 | | // record, |
| | | 46 | | // e, null); |
| | | 47 | | //} |
| | 0 | 48 | | } |
| | | 49 | | |
| | | 50 | | internal static void TraceDroppedMessage(Message requestMessage, EndpointDispatcher endpoint) |
| | | 51 | | { |
| | | 52 | | //if (DiagnosticUtility.ShouldTraceInformation) |
| | | 53 | | //{ |
| | | 54 | | // EndpointAddress endpointAddress = null; |
| | | 55 | | // if (dispatcher != null) |
| | | 56 | | // { |
| | | 57 | | // endpointAddress = dispatcher.EndpointAddress; |
| | | 58 | | // } |
| | | 59 | | // TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.DroppedAMessage, |
| | | 60 | | // SR.Format(SR.TraceCodeDroppedAMessage), new MessageDroppedTraceRecord(message, endpointAddress)); |
| | | 61 | | //} |
| | 2 | 62 | | } |
| | | 63 | | |
| | | 64 | | internal static Exception ThrowHelperArgumentNull(string v, Message message) |
| | | 65 | | { |
| | 0 | 66 | | return new Exception(v); |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | internal static Exception ThrowHelperWarning(Exception exception, Message request) |
| | | 70 | | { |
| | 0 | 71 | | return exception; |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |