From 393ade4a5cf25395f62360722a67f06918ebbf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=20Wyman=20=E2=88=9E?= Date: Wed, 2 May 2018 12:26:08 -0400 Subject: [PATCH] vsts: improve tracing Adopt the dedicated trace method for handling exceptions. --- .../BaseVstsAuthentication.cs | 12 ++++++++---- Microsoft.Vsts.Authentication/TokenRegistry.cs | 2 +- .../VstsAadAuthentication.cs | 2 +- Microsoft.Vsts.Authentication/VstsAdalTokenCache.cs | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Microsoft.Vsts.Authentication/BaseVstsAuthentication.cs b/Microsoft.Vsts.Authentication/BaseVstsAuthentication.cs index 5fb86f5..fd970b3 100644 --- a/Microsoft.Vsts.Authentication/BaseVstsAuthentication.cs +++ b/Microsoft.Vsts.Authentication/BaseVstsAuthentication.cs @@ -235,7 +235,8 @@ namespace Microsoft.Alm.Authentication } catch (HttpRequestException exception) { - context.Trace.WriteLine($"unable to get response from '{targetUri}' due to '{exception.Message}'."); + context.Trace.WriteLine($"unable to get response from '{targetUri}', an error occurred before the server could respond."); + context.Trace.WriteException(exception); } } else @@ -427,7 +428,8 @@ namespace Microsoft.Alm.Authentication { System.Diagnostics.Debug.WriteLine(exception); - Trace.WriteLine($"failed to write credentials to the secure store: {exception.GetType().Name}."); + Trace.WriteLine($"failed to write credentials to the secure store."); + Trace.WriteException(exception); } } @@ -473,7 +475,8 @@ namespace Microsoft.Alm.Authentication { System.Diagnostics.Debug.WriteLine(exception); - context.Trace.WriteLine($"failed to deserialize tenant cache: {exception.GetType().Name}."); + context.Trace.WriteLine($"failed to deserialize tenant cache."); + context.Trace.WriteException(exception); return cache; } @@ -579,7 +582,8 @@ namespace Microsoft.Alm.Authentication { System.Diagnostics.Debug.WriteLine(exception); - context.Trace.WriteLine($"failed to serialize tenant cache: {exception.GetType().Name}."); + context.Trace.WriteLine($"failed to serialize tenant cache."); + context.Trace.WriteException(exception); } } } diff --git a/Microsoft.Vsts.Authentication/TokenRegistry.cs b/Microsoft.Vsts.Authentication/TokenRegistry.cs index 6483e68..e5d2519 100644 --- a/Microsoft.Vsts.Authentication/TokenRegistry.cs +++ b/Microsoft.Vsts.Authentication/TokenRegistry.cs @@ -222,7 +222,7 @@ namespace Microsoft.Alm.Authentication } catch (Exception exception) { - context.Trace.WriteLine($"! {exception.Message}"); + context.Trace.WriteException(exception); } yield return result; diff --git a/Microsoft.Vsts.Authentication/VstsAadAuthentication.cs b/Microsoft.Vsts.Authentication/VstsAadAuthentication.cs index 41b5f4e..c03b0f2 100644 --- a/Microsoft.Vsts.Authentication/VstsAadAuthentication.cs +++ b/Microsoft.Vsts.Authentication/VstsAadAuthentication.cs @@ -191,7 +191,7 @@ namespace Microsoft.Alm.Authentication /// /// Compact tokens are necessary for clients which have restrictions on the size of the basic authentication header which they can create (example: Git). /// - [Obsolete("Please use Task NoninteractiveLogon(TargetUri targetUri, PersonalAccessTokenOptions options) instead.", false)] + [Obsolete("Use Task NoninteractiveLogon(TargetUri targetUri, PersonalAccessTokenOptions options) instead.", false)] public async Task NoninteractiveLogon(TargetUri targetUri, bool requestCompactToken) { BaseSecureStore.ValidateTargetUri(targetUri); diff --git a/Microsoft.Vsts.Authentication/VstsAdalTokenCache.cs b/Microsoft.Vsts.Authentication/VstsAdalTokenCache.cs index b7ce1d7..8e8661f 100644 --- a/Microsoft.Vsts.Authentication/VstsAdalTokenCache.cs +++ b/Microsoft.Vsts.Authentication/VstsAdalTokenCache.cs @@ -92,7 +92,8 @@ namespace Microsoft.Alm.Authentication } catch (Exception exception) { - _context.Trace.WriteLine($"error: {nameof(VstsAdalTokenCache)} \"{_cacheFilePath}\": {exception.Message}"); + _context.Trace.WriteLine($"error: {nameof(VstsAdalTokenCache)} \"{_cacheFilePath}\"."); + _context.Trace.WriteException(exception); } } } @@ -114,7 +115,8 @@ namespace Microsoft.Alm.Authentication } catch (Exception exception) { - _context.Trace.WriteLine($"error: {nameof(VstsAdalTokenCache)} \"{_cacheFilePath}\": {exception.Message}"); + _context.Trace.WriteLine($"error: {nameof(VstsAdalTokenCache)} \"{_cacheFilePath}\"."); + _context.Trace.WriteException(exception); } } }