@@ -23,13 +23,13 @@ public static string GetHostName()
2323 {
2424 name = NameResolutionPal . GetHostName ( ) ;
2525 }
26- catch ( Exception ex ) when ( LogFailure ( string . Empty , startingTimestamp , ex ) )
26+ catch when ( LogFailure ( string . Empty , startingTimestamp ) )
2727 {
2828 Debug . Fail ( "LogFailure should return false" ) ;
2929 throw ;
3030 }
3131
32- NameResolutionTelemetry . Log . AfterResolution ( string . Empty , startingTimestamp ) ;
32+ NameResolutionTelemetry . Log . AfterResolution ( string . Empty , startingTimestamp , successful : true ) ;
3333
3434 if ( NetEventSource . Log . IsEnabled ( ) ) NetEventSource . Info ( null , name ) ;
3535 return name ;
@@ -394,13 +394,13 @@ private static object GetHostEntryOrAddressesCore(string hostName, bool justAddr
394394 Aliases = aliases
395395 } ;
396396 }
397- catch ( Exception ex ) when ( LogFailure ( hostName , startingTimestamp , ex ) )
397+ catch when ( LogFailure ( hostName , startingTimestamp ) )
398398 {
399399 Debug . Fail ( "LogFailure should return false" ) ;
400400 throw ;
401401 }
402402
403- NameResolutionTelemetry . Log . AfterResolution ( hostName , startingTimestamp ) ;
403+ NameResolutionTelemetry . Log . AfterResolution ( hostName , startingTimestamp , successful : true ) ;
404404
405405 return result ;
406406 }
@@ -434,13 +434,13 @@ private static object GetHostEntryOrAddressesCore(IPAddress address, bool justAd
434434 }
435435 Debug . Assert ( name != null ) ;
436436 }
437- catch ( Exception ex ) when ( LogFailure ( address , startingTimestamp , ex ) )
437+ catch when ( LogFailure ( address , startingTimestamp ) )
438438 {
439439 Debug . Fail ( "LogFailure should return false" ) ;
440440 throw ;
441441 }
442442
443- NameResolutionTelemetry . Log . AfterResolution ( address , startingTimestamp ) ;
443+ NameResolutionTelemetry . Log . AfterResolution ( address , startingTimestamp , successful : true ) ;
444444
445445 // Do the forward lookup to get the IPs for that host name
446446 startingTimestamp = NameResolutionTelemetry . Log . BeforeResolution ( name ) ;
@@ -464,13 +464,13 @@ private static object GetHostEntryOrAddressesCore(IPAddress address, bool justAd
464464 AddressList = addresses
465465 } ;
466466 }
467- catch ( Exception ex ) when ( LogFailure ( name , startingTimestamp , ex ) )
467+ catch when ( LogFailure ( name , startingTimestamp ) )
468468 {
469469 Debug . Fail ( "LogFailure should return false" ) ;
470470 throw ;
471471 }
472472
473- NameResolutionTelemetry . Log . AfterResolution ( name , startingTimestamp ) ;
473+ NameResolutionTelemetry . Log . AfterResolution ( name , startingTimestamp , successful : true ) ;
474474
475475 // One of three things happened:
476476 // 1. Success.
@@ -577,7 +577,7 @@ private static Task GetHostEntryOrAddressesCoreAsync(string hostName, bool justR
577577 }
578578
579579 private static Task < T > ? GetAddrInfoWithTelemetryAsync < T > ( string hostName , bool justAddresses , AddressFamily addressFamily , CancellationToken cancellationToken )
580- where T : class
580+ where T : class
581581 {
582582 long startingTimestamp = Stopwatch . GetTimestamp ( ) ;
583583 Task ? task = NameResolutionPal . GetAddrInfoAsync ( hostName , justAddresses , addressFamily , cancellationToken ) ;
@@ -594,19 +594,15 @@ private static Task GetHostEntryOrAddressesCoreAsync(string hostName, bool justR
594594 static async Task < T > CompleteAsync ( Task task , string hostName , long startingTimestamp )
595595 {
596596 _ = NameResolutionTelemetry . Log . BeforeResolution ( hostName ) ;
597- Exception ? exception = null ;
597+ T ? result = null ;
598598 try
599599 {
600- return await ( ( Task < T > ) task ) . ConfigureAwait ( false ) ;
601- }
602- catch ( Exception ex )
603- {
604- exception = ex ;
605- throw ;
600+ result = await ( ( Task < T > ) task ) . ConfigureAwait ( false ) ;
601+ return result ;
606602 }
607603 finally
608604 {
609- NameResolutionTelemetry . Log . AfterResolution ( hostName , startingTimestamp , exception ) ;
605+ NameResolutionTelemetry . Log . AfterResolution ( hostName , startingTimestamp , successful : result is not null ) ;
610606 }
611607 }
612608 }
@@ -631,9 +627,9 @@ private static void ValidateHostName(string hostName)
631627 }
632628 }
633629
634- private static bool LogFailure ( object hostNameOrAddress , long ? startingTimestamp , Exception exception )
630+ private static bool LogFailure ( object hostNameOrAddress , long ? startingTimestamp )
635631 {
636- NameResolutionTelemetry . Log . AfterResolution ( hostNameOrAddress , startingTimestamp , exception ) ;
632+ NameResolutionTelemetry . Log . AfterResolution ( hostNameOrAddress , startingTimestamp , successful : false ) ;
637633 return false ;
638634 }
639635
0 commit comments