diff --git a/DigitalData.Auth.Abstractions/IAuthClient.cs b/DigitalData.Auth.Abstractions/IAuthClient.cs index c082138..305cb16 100644 --- a/DigitalData.Auth.Abstractions/IAuthClient.cs +++ b/DigitalData.Auth.Abstractions/IAuthClient.cs @@ -4,10 +4,6 @@ public interface IAuthClient : IAuthListenHandler, IAuthSenderHandler { bool IsConnected { get; } - Exception? ConnectionError { get; } - - bool IsConnectionFailed => ConnectionError is not null; - Task StartAsync(); Task TryStartAsync(); diff --git a/DigitalData.Auth.Client/AuthClient.cs b/DigitalData.Auth.Client/AuthClient.cs index 98bb3dd..f3936c3 100644 --- a/DigitalData.Auth.Client/AuthClient.cs +++ b/DigitalData.Auth.Client/AuthClient.cs @@ -29,38 +29,27 @@ public class AuthClient : IAuthClient, IAsyncDisposable _connection.On(nameof(ReceivePublicKeyAsync), ReceivePublicKeyAsync); - _logger = logger; - - _lazyInitiator = new(async () => - { - try - { - await _connection.StartAsync(); - IsConnected = true; - return true; - } - catch(Exception ex) - { - ConnectionError = ex; - throw; - } - }); + _logger = logger; } public bool IsConnected { get; private set; } = false; - public Exception? ConnectionError { get; private set; } - - public async Task StartAsync() => await _lazyInitiator.Value; + public async Task StartAsync() + { + await _connection.StartAsync(); + IsConnected = true; + } public async Task TryStartAsync() { try { - return await _lazyInitiator.Value; + await StartAsync(); + return true; } - catch + catch(Exception ex) { + _logger?.LogError(ex, "{message}", ex.Message); return false; } }