Add Sentry to catch exceptions.

This commit is contained in:
2025-08-20 18:51:05 +01:00
parent d5ef2c874d
commit c1f4b92548
70 changed files with 1213 additions and 1087 deletions

View File

@@ -45,6 +45,7 @@ using Aaru.Logging;
using Avalonia.Controls;
using Avalonia.Threading;
using ReactiveUI;
using Sentry;
namespace Aaru.Gui.ViewModels.Windows;
@@ -123,9 +124,10 @@ public sealed class ImageChecksumViewModel : ViewModelBase
{
ChecksumTracksVisible = (inputFormat as IOpticalMediaImage)?.Tracks?.Count > 0;
}
catch
catch(Exception ex)
{
ChecksumTracksVisible = false;
SentrySdk.CaptureException(ex);
}
}
@@ -404,8 +406,10 @@ public sealed class ImageChecksumViewModel : ViewModelBase
{
formatHasTracks = opticalMediaImage.Tracks?.Count > 0;
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
formatHasTracks = false;
}
}
@@ -494,9 +498,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
i));
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, errno, i));
_cancel = true;
@@ -508,10 +510,10 @@ public sealed class ImageChecksumViewModel : ViewModelBase
}
AaruLogging.Debug(MODULE_NAME,
UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
currentTrack.Sequence,
currentTrack.StartSector,
currentTrack.EndSector);
UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
currentTrack.Sequence,
currentTrack.StartSector,
currentTrack.EndSector);
if(ChecksumTracksChecked) trackChecksum = new Checksum(enabledChecksums);
@@ -544,8 +546,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
doneSectors));
errno,
doneSectors));
_cancel = true;
@@ -574,8 +576,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
doneSectors));
errno,
doneSectors));
_cancel = true;
@@ -637,9 +639,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
i));
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, errno, i));
_cancel = true;
@@ -702,8 +702,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
doneSectors));
errno,
doneSectors));
_cancel = true;
@@ -732,8 +732,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1,
errno,
doneSectors));
errno,
doneSectors));
_cancel = true;

View File

@@ -58,6 +58,7 @@ using Avalonia.Threading;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;
using ReactiveUI;
using Sentry;
using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo;
using Track = Aaru.CommonTypes.Structs.Track;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -630,8 +631,10 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
tracks = inputOptical?.Tracks;
}
catch(Exception)
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
tracks = null;
}
@@ -2125,8 +2128,10 @@ public sealed class ImageConvertViewModel : ViewModelBase
fs.Close();
MetadataJsonText = result[0].Path.AbsolutePath;
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
await MessageBoxManager
.GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_metadata_sidecar_file, icon: Icon.Error)
.ShowWindowDialogAsync(_view);
@@ -2181,8 +2186,10 @@ public sealed class ImageConvertViewModel : ViewModelBase
.ShowWindowDialogAsync(_view);
}
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_resume_file, icon: Icon.Error)
.ShowWindowDialogAsync(_view);
}

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2025 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
@@ -47,6 +48,7 @@ using Avalonia.Threading;
using Humanizer;
using Humanizer.Localisation;
using ReactiveUI;
using Sentry;
namespace Aaru.Gui.ViewModels.Windows;
@@ -365,8 +367,10 @@ public sealed class ImageVerifyViewModel : ViewModelBase
{
formatHasTracks = inputOptical?.Tracks?.Count > 0;
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
formatHasTracks = false;
}
@@ -440,7 +444,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase
});
AaruLogging.Verbose(UI.Checking_disc_image_checksums_took_0,
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
}
}
@@ -612,7 +616,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase
}
AaruLogging.Verbose(UI.Checking_sector_checksums_took_0,
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
await Dispatcher.UIThread.InvokeAsync(() =>
{

View File

@@ -63,6 +63,7 @@ using JetBrains.Annotations;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;
using ReactiveUI;
using Sentry;
using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo;
using Dump = Aaru.Core.Devices.Dumping.Dump;
using File = System.IO.File;
@@ -535,8 +536,10 @@ public sealed class MediaDumpViewModel : ViewModelBase
fs.Close();
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
// ReSharper disable AssignmentIsFullyDiscarded
_ = MessageBoxManager.
@@ -728,8 +731,10 @@ public sealed class MediaDumpViewModel : ViewModelBase
sr.Close();
}
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
await MessageBoxManager
.GetMessageBoxStandard(UI.Title_Error,
UI.Incorrect_resume_file_cannot_use_it,

View File

@@ -47,6 +47,7 @@ using Aaru.Settings;
using Avalonia.Threading;
using Microsoft.EntityFrameworkCore;
using ReactiveUI;
using Sentry;
namespace Aaru.Gui.ViewModels.Windows;
@@ -134,9 +135,10 @@ public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase
ctx?.Database.CloseConnection();
ctx?.Dispose();
}
catch(Exception)
catch(Exception ex)
{
// Should not ever arrive here, but if it does, keep trying to replace it anyway
SentrySdk.CaptureException(ex);
}
File.Delete(Settings.Settings.LocalDbPath);
@@ -212,12 +214,14 @@ public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase
{
File.Delete(Settings.Settings.MainDbPath);
}
catch(Exception)
catch(Exception ex)
{
AaruLogging.Error(UI.Exception_trying_to_remove_old_database_version);
AaruLogging.Error(UI.Please_manually_remove_file_at_0, Settings.Settings.MainDbPath);
SentrySdk.CaptureException(ex);
return;
}