Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing exception logging #130

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion vATIS.Desktop/Atis/AtisBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ public async Task UpdateIds(AtisStation station, AtisPreset preset, char current
}
catch (HttpRequestException ex)
{
Log.Error(ex.ToString());
Log.Error(ex.ToString(), "HttpRequestException updating IDS");
}
catch (Exception ex)
{
Log.Error(ex, "Failed to update IDS");
throw new AtisBuilderException($"Failed to Update IDS: " + ex.Message);
}
}
Expand Down
5 changes: 5 additions & 0 deletions vATIS.Desktop/TextToSpeech/TextToSpeechService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public async Task Initialize()
}
catch (OperationCanceledException)
{
// Ignored
}
catch (Exception ex)
{
Log.Error(ex, "Error requesting audio");
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using Serilog;
using Vatsim.Vatis.Atis;
using Vatsim.Vatis.Events;
using Vatsim.Vatis.Events.EventBus;
Expand Down Expand Up @@ -409,8 +410,9 @@ private async Task HandleRefreshSandboxAtis()
SandboxSpokenTextAtis = AtisBuilderVoiceResponse.SpokenText?.ToUpperInvariant();
}
}
catch (Exception)
catch (Exception ex)
{
Log.Error(ex, "HandleRefreshSandboxAtis Exception");
SandboxTextAtis = "";
SandboxSpokenTextAtis = "";
throw;
Expand Down
13 changes: 13 additions & 0 deletions vATIS.Desktop/Ui/ViewModels/AtisStationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (Exception e)
{
Log.Error(e, "HandleVoiceRecordAtisCommand Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down Expand Up @@ -887,6 +888,7 @@ private async void HandleNetworkStatusChanged(NetworkConnectionStatus status)
}
catch (Exception ex)
{
Log.Error(ex, "Error connecting to voice server");
ErrorMessage = ex.Message;
}

Expand All @@ -908,6 +910,7 @@ private async void HandleNetworkStatusChanged(NetworkConnectionStatus status)
}
catch (Exception ex)
{
Log.Error(ex, "Error disconnecting from voice server");
ErrorMessage = ex.Message;
}

Expand All @@ -923,6 +926,7 @@ private async void HandleNetworkStatusChanged(NetworkConnectionStatus status)
}
catch (Exception e)
{
Log.Error(e, "HandleNetworkStatusChanged Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down Expand Up @@ -992,6 +996,7 @@ private async void HandleNetworkConnect()
}
catch (Exception e)
{
Log.Error(e, "HandleNetworkConnect Exception");
NativeAudio.EmitSound(SoundType.Error);
ErrorMessage = e.Message;
_networkConnection?.Disconnect();
Expand All @@ -1006,6 +1011,7 @@ private async void HandleNetworkConnect()
}
catch (Exception e)
{
Log.Error(e, "HandleNetworkConnect Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down Expand Up @@ -1116,6 +1122,7 @@ private async void OnMetarResponseReceived(object? sender, MetarResponseReceived
}
catch (Exception ex)
{
Log.Error(ex, "Failed to update METAR properties.");
propertyUpdates.SetException(ex);
}
});
Expand Down Expand Up @@ -1191,6 +1198,7 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (Exception ex)
{
Log.Error(ex, "OnMetarResponseReceived Exception");
ErrorMessage = ex.Message;
_networkConnection?.Disconnect();
NativeAudio.EmitSound(SoundType.Error);
Expand All @@ -1199,6 +1207,7 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (Exception ex)
{
Log.Error(ex, "OnMetarResponseReceived Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down Expand Up @@ -1339,9 +1348,11 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (OperationCanceledException)
{
// Ignored
}
catch (Exception e)
{
Log.Error(e, "HandleSelectedAtisPresetChanged Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down Expand Up @@ -1521,6 +1532,7 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (Exception ex)
{
Log.Error(ex, "HandleAtisLetterChanged Exception");
Dispatcher.UIThread.Post(() => { ErrorMessage = ex.Message; });
}
}, _cancellationToken.Token);
Expand All @@ -1531,6 +1543,7 @@ await _voiceServerConnection.AddOrUpdateBot(_networkConnection.Callsign, dto,
}
catch (Exception e)
{
Log.Error(e, "HandleAtisLetterChanged Exception");
Dispatcher.UIThread.Post(() =>
{
Wind = null;
Expand Down
2 changes: 2 additions & 0 deletions vATIS.Desktop/Ui/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using Serilog;
using Vatsim.Vatis.Events;
using Vatsim.Vatis.Events.EventBus;
using Vatsim.Vatis.Networking;
Expand Down Expand Up @@ -346,6 +347,7 @@ public async Task PopulateAtisStations()
}
catch (Exception ex)
{
Log.Error(ex, "Error Populating ATIS Station");
if (Owner != null)
{
await MessageBox.ShowDialog(Owner, "Error populating ATIS station: " + ex.Message, "Error",
Expand Down
2 changes: 2 additions & 0 deletions vATIS.Desktop/Voice/Network/VoiceServerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public async Task AddOrUpdateBot(string callsign, PutBotRequestDto dto, Cancella
}
catch (Exception ex)
{
Log.Error(ex, "AddOrUpdateBot failed.");
throw new AtisBuilderException("AddOrUpdateBot action failed: " + ex.Message);
}
}
Expand All @@ -109,6 +110,7 @@ public async Task RemoveBot(string callsign, CancellationToken? cancellationToke
}
catch (Exception ex)
{
Log.Error(ex, "RemoveBot failed.");
throw new AtisBuilderException("RemoveBot action failed: " + ex.Message);
}
}
Expand Down
Loading