Skip to content

Commit

Permalink
OnCoreException was added (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraFinebits authored Jun 29, 2024
1 parent 7738c30 commit 9a6596a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Eppie.CLI/Eppie.CLI/Menu/Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal class Actions(

internal void ExitAction()
{
_coreProvider.TuviMailCore.ExceptionOccurred -= OnCoreException;
_logger.LogMethodCall();
_application.StopApplication();
}
Expand Down Expand Up @@ -75,6 +76,8 @@ internal async Task InitActionAsync()

bool success = await _coreProvider.TuviMailCore.InitializeApplicationAsync(password).ConfigureAwait(false);

_coreProvider.TuviMailCore.ExceptionOccurred += OnCoreException;

if (success)
{
_application.WriteApplicationInitializationMessage(seedPhrase);
Expand Down Expand Up @@ -471,5 +474,14 @@ private async Task AddDecAccountAsync()
account.Type = (int)MailBoxType.Dec;
await _coreProvider.TuviMailCore.AddAccountAsync(account).ConfigureAwait(false);
}

private void OnCoreException(object? sender, ExceptionEventArgs e)
{
_logger.LogMethodCall();

ArgumentNullException.ThrowIfNull(e);

_application.WriteError(e.Exception);
}
}
}

0 comments on commit 9a6596a

Please sign in to comment.