diff --git a/Aaru.Checksums/Aaru.Checksums.csproj b/Aaru.Checksums/Aaru.Checksums.csproj index 2a8057075..eba107ccc 100644 --- a/Aaru.Checksums/Aaru.Checksums.csproj +++ b/Aaru.Checksums/Aaru.Checksums.csproj @@ -54,4 +54,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Checksums/Native.cs b/Aaru.Checksums/Native.cs index cd9f1e3a0..c3c2ec5a5 100644 --- a/Aaru.Checksums/Native.cs +++ b/Aaru.Checksums/Native.cs @@ -30,7 +30,9 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Runtime.InteropServices; +using Sentry; namespace Aaru.Checksums; @@ -62,10 +64,12 @@ public static partial class Native { version = get_acn_version(); } - catch + catch(Exception ex) { _supported = false; + SentrySdk.CaptureException(ex); + return false; } diff --git a/Aaru.CommonTypes/Aaru.CommonTypes.csproj b/Aaru.CommonTypes/Aaru.CommonTypes.csproj index 446adcc89..c3c89e9fa 100644 --- a/Aaru.CommonTypes/Aaru.CommonTypes.csproj +++ b/Aaru.CommonTypes/Aaru.CommonTypes.csproj @@ -55,4 +55,9 @@ Localization.Designer.cs + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + diff --git a/Aaru.CommonTypes/Interop/DetectOS.cs b/Aaru.CommonTypes/Interop/DetectOS.cs index 128759b1d..e7af75151 100644 --- a/Aaru.CommonTypes/Interop/DetectOS.cs +++ b/Aaru.CommonTypes/Interop/DetectOS.cs @@ -42,6 +42,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using System.Security.Principal; +using Sentry; namespace Aaru.CommonTypes.Interop; @@ -86,8 +87,10 @@ public static partial class DetectOS { isAdmin = false; } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + isAdmin = false; } finally @@ -237,7 +240,7 @@ public static partial class DetectOS /// Current operating system version public static string GetVersion() { - var environ = Environment.OSVersion.Version.ToString(); + string environ = Environment.OSVersion.Version.ToString(); switch(GetRealPlatformID()) { diff --git a/Aaru.CommonTypes/PluginRegister.cs b/Aaru.CommonTypes/PluginRegister.cs index eb78040fe..bd77be727 100644 --- a/Aaru.CommonTypes/PluginRegister.cs +++ b/Aaru.CommonTypes/PluginRegister.cs @@ -36,6 +36,7 @@ using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Microsoft.Extensions.DependencyInjection; +using Sentry; namespace Aaru.CommonTypes; @@ -273,9 +274,10 @@ public class PluginRegister else noFilter = filter; } - catch(IOException) + catch(IOException ex) { // Ignore and continue + SentrySdk.CaptureException(ex); } } diff --git a/Aaru.Compression/Aaru.Compression.csproj b/Aaru.Compression/Aaru.Compression.csproj index 7c378c795..17b5cb7ac 100644 --- a/Aaru.Compression/Aaru.Compression.csproj +++ b/Aaru.Compression/Aaru.Compression.csproj @@ -72,4 +72,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Compression/Native.cs b/Aaru.Compression/Native.cs index 6a0ee9485..73bf509b6 100644 --- a/Aaru.Compression/Native.cs +++ b/Aaru.Compression/Native.cs @@ -30,7 +30,9 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Runtime.InteropServices; +using Sentry; namespace Aaru.Compression; @@ -62,8 +64,10 @@ public static partial class Native { version = AARU_get_acn_version(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + _supported = false; return false; diff --git a/Aaru.Core/Aaru.Core.csproj b/Aaru.Core/Aaru.Core.csproj index 47ee2d8ad..1a39a8946 100644 --- a/Aaru.Core/Aaru.Core.csproj +++ b/Aaru.Core/Aaru.Core.csproj @@ -74,6 +74,9 @@ + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + ..\..\..\..\.nuget\packages\spectre.console.json\0.50.0\lib\net9.0\Spectre.Console.Json.dll diff --git a/Aaru.Core/ArchiveFormat.cs b/Aaru.Core/ArchiveFormat.cs index 9cfcd7e62..cdc693472 100644 --- a/Aaru.Core/ArchiveFormat.cs +++ b/Aaru.Core/ArchiveFormat.cs @@ -30,9 +30,11 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Logging; +using Sentry; namespace Aaru.Core; @@ -67,18 +69,19 @@ public static class ArchiveFormat break; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } } // Not recognized return format; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return null; } } diff --git a/Aaru.Core/DataFile.cs b/Aaru.Core/DataFile.cs index 3a10b4ec3..10fb3a3ac 100644 --- a/Aaru.Core/DataFile.cs +++ b/Aaru.Core/DataFile.cs @@ -30,10 +30,12 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Diagnostics.CodeAnalysis; using System.IO; using Aaru.Helpers; using Aaru.Logging; +using Sentry; namespace Aaru.Core; @@ -150,8 +152,10 @@ public sealed class DataFile outputFs.Write(data, 0, data.Length); outputFs.Close(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + AaruLogging.Exception(ex, Localization.Core.Unable_to_write_file_0, filename); AaruLogging.Error(Localization.Core.Unable_to_write_file_0, filename); } } diff --git a/Aaru.Core/Devices/Report/MMC.cs b/Aaru.Core/Devices/Report/MMC.cs index 604cb0aea..130477d96 100644 --- a/Aaru.Core/Devices/Report/MMC.cs +++ b/Aaru.Core/Devices/Report/MMC.cs @@ -40,6 +40,7 @@ using Aaru.Decoders.SCSI.MMC; using Aaru.Devices; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Spectre.Console; namespace Aaru.Core.Devices.Report; @@ -514,12 +515,10 @@ public sealed partial class DeviceReport int.Parse(ssecond), DateTimeKind.Utc); } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } } @@ -947,8 +946,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadSpareAreaInformation); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadSpareAreaInformation); mediaTest.DvdSaiData = buffer; @@ -993,8 +992,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadSpareAreaInformation); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadSpareAreaInformation); mediaTest.BluSaiData = buffer; } @@ -1055,9 +1054,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRecordablePFI); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadRecordablePFI); mediaTest.EmbossedPfiData = buffer; } @@ -1142,9 +1139,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadLayerCapacity); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadLayerCapacity); mediaTest.DvdLayerData = buffer; } @@ -1172,9 +1167,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadDiscInformation); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadDiscInformation); mediaTest.BluDiData = buffer; @@ -1418,9 +1411,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCd); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCd); mediaTest.ReadCdFullData = buffer; @@ -1445,9 +1436,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCdMsf); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsf); mediaTest.ReadCdMsfFullData = buffer; } @@ -1475,9 +1464,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCd); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCd); mediaTest.ReadCdData = buffer; @@ -1502,9 +1489,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCdMsf); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsf); mediaTest.ReadCdMsfData = buffer; @@ -1530,9 +1515,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCdRaw); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdRaw); mediaTest.ReadCdFullData = buffer; @@ -1557,9 +1540,7 @@ public sealed partial class DeviceReport out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsReadCdMsfRaw); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsfRaw); mediaTest.ReadCdMsfFullData = buffer; } @@ -1734,9 +1715,7 @@ public sealed partial class DeviceReport } }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadLeadOut); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadLeadOut); mediaTest.LeadOutData = buffer; } @@ -1790,8 +1769,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadC2Pointers); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; } @@ -1819,8 +1798,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; @@ -1842,8 +1821,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -1870,8 +1849,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; } @@ -1928,8 +1907,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; @@ -1971,8 +1950,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; @@ -2014,8 +1993,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; } @@ -2070,8 +2049,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadC2Pointers); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; } @@ -2099,8 +2078,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; @@ -2122,8 +2101,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -2150,8 +2129,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; } @@ -2207,8 +2186,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; @@ -2250,8 +2229,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; @@ -2298,8 +2277,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; } @@ -2354,9 +2333,7 @@ public sealed partial class DeviceReport } }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadC2Pointers); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; } @@ -2383,8 +2360,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; @@ -2406,8 +2383,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -2434,8 +2411,8 @@ public sealed partial class DeviceReport out _); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannel); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; } @@ -2491,8 +2468,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadPQSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; @@ -2534,8 +2511,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadRWSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; @@ -2577,8 +2554,8 @@ public sealed partial class DeviceReport } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadCorrectedSubchannelWithC2); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; } @@ -2603,8 +2580,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsPlextorReadCDDA); + Localization.Core.Sense_equals_0, + !mediaTest.SupportsPlextorReadCDDA); mediaTest.PlextorReadCddaData = buffer; } @@ -2627,8 +2604,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsPioneerReadCDDA); + Localization.Core.Sense_equals_0, + !mediaTest.SupportsPioneerReadCDDA); mediaTest.PioneerReadCddaData = buffer; @@ -2648,8 +2625,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsPioneerReadCDDAMSF); + Localization.Core.Sense_equals_0, + !mediaTest.SupportsPioneerReadCDDAMSF); mediaTest.PioneerReadCddaMsfData = buffer; } @@ -2664,9 +2641,7 @@ public sealed partial class DeviceReport !_dev.NecReadCdDa(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsNECReadCDDA); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsNECReadCDDA); mediaTest.NecReadCddaData = buffer; } @@ -2727,9 +2702,7 @@ public sealed partial class DeviceReport !_dev.PlextorReadRawDvd(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsPlextorReadRawDVD); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsPlextorReadRawDVD); if(mediaTest.SupportsPlextorReadRawDVD == true) mediaTest.SupportsPlextorReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); @@ -2747,9 +2720,7 @@ public sealed partial class DeviceReport !_dev.HlDtStReadRawDvd(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _, 0xffff, false); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsHLDTSTReadRawDVD); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsHLDTSTReadRawDVD); if(mediaTest.SupportsHLDTSTReadRawDVD == true) mediaTest.SupportsHLDTSTReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); @@ -2767,9 +2738,7 @@ public sealed partial class DeviceReport !_dev.LiteOnReadRawDvd(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _, 0xffff, false); }); - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.SupportsLiteOnReadRawDVD); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsLiteOnReadRawDVD); if(mediaTest.SupportsLiteOnReadRawDVD == true) mediaTest.SupportsLiteOnReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); @@ -3035,9 +3004,7 @@ public sealed partial class DeviceReport mediaTest.ReadF1_06LeadOutData = senseBuffer; } - AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadF1_06LeadOut); + AaruLogging.Debug(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadF1_06LeadOut); }); } @@ -3067,7 +3034,7 @@ public sealed partial class DeviceReport if(!decodedToc.TrackDescriptors.Any(t => t.SessionNumber > 1)) { AaruLogging.Error(Localization.Core - .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); + .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); return null; } @@ -3081,22 +3048,22 @@ public sealed partial class DeviceReport if(firstSessionLeadOutTrack.SessionNumber == 0 || secondSessionFirstTrack.SessionNumber == 0) { AaruLogging.Error(Localization.Core - .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); + .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); return null; } AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.First_session_Lead_Out_starts_at_0_1_2, - firstSessionLeadOutTrack.PMIN, - firstSessionLeadOutTrack.PSEC, - firstSessionLeadOutTrack.PFRAME); + Localization.Core.First_session_Lead_Out_starts_at_0_1_2, + firstSessionLeadOutTrack.PMIN, + firstSessionLeadOutTrack.PSEC, + firstSessionLeadOutTrack.PFRAME); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Second_session_starts_at_0_1_2, - secondSessionFirstTrack.PMIN, - secondSessionFirstTrack.PSEC, - secondSessionFirstTrack.PFRAME); + Localization.Core.Second_session_starts_at_0_1_2, + secondSessionFirstTrack.PMIN, + secondSessionFirstTrack.PSEC, + secondSessionFirstTrack.PFRAME); // Skip Lead-Out pre-gap uint firstSessionLeadOutLba = (uint)(firstSessionLeadOutTrack.PMIN * 60 * 75 + @@ -3172,8 +3139,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadingIntersessionLeadOut); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadingIntersessionLeadOut); mediaTest.IntersessionLeadOutData = buffer; @@ -3239,8 +3206,8 @@ public sealed partial class DeviceReport }); AaruLogging.Debug(SCSI_MODULE_NAME, - Localization.Core.Sense_equals_0, - !mediaTest.CanReadingIntersessionLeadIn); + Localization.Core.Sense_equals_0, + !mediaTest.CanReadingIntersessionLeadIn); mediaTest.IntersessionLeadInData = buffer; } diff --git a/Aaru.Core/ImageFormat.cs b/Aaru.Core/ImageFormat.cs index 0f12ec59e..bd7dbb9bc 100644 --- a/Aaru.Core/ImageFormat.cs +++ b/Aaru.Core/ImageFormat.cs @@ -34,6 +34,7 @@ using System; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Logging; +using Sentry; namespace Aaru.Core; @@ -70,10 +71,9 @@ public static class ImageFormat break; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } } @@ -96,10 +96,9 @@ public static class ImageFormat break; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } } @@ -122,18 +121,19 @@ public static class ImageFormat break; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } } // Still not recognized return imageFormat; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return null; } } diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index 49c4af3c2..875a76e0f 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -52,6 +52,7 @@ using Aaru.Helpers; using Aaru.Logging; using Humanizer; using Humanizer.Bytes; +using Sentry; using Spectre.Console; using Spectre.Console.Json; using DDS = Aaru.Decoders.DVD.DDS; @@ -905,9 +906,9 @@ public static class ImageInfo AaruLogging.WriteLine(); } } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try @@ -989,9 +990,9 @@ public static class ImageInfo AnsiConsole.Write(table); } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } finally { diff --git a/Aaru.Core/Logging/DeviceLog.cs b/Aaru.Core/Logging/DeviceLog.cs index d96ec764c..a775a4e1d 100644 --- a/Aaru.Core/Logging/DeviceLog.cs +++ b/Aaru.Core/Logging/DeviceLog.cs @@ -35,6 +35,7 @@ using System.IO; using Aaru.CommonTypes.Interop; using Aaru.Devices; using Aaru.Logging; +using Sentry; namespace Aaru.Core.Logging; @@ -60,9 +61,10 @@ public static class DeviceLog { args[i] = Path.GetFileName(args[i]); } - catch + catch(Exception ex) { // Do nothing + SentrySdk.CaptureException(ex); } } diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index ea5db2332..086180da9 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -47,6 +47,7 @@ using Aaru.Decoders.Sega; using Aaru.Devices; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using DMI = Aaru.Decoders.Xbox.DMI; using Sector = Aaru.Decoders.CD.Sector; @@ -1636,8 +1637,10 @@ public static class MMC isoSector = rootMs.ToArray(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } @@ -1697,8 +1700,10 @@ public static class MMC isoSector = pcdMs.ToArray(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } @@ -2151,8 +2156,10 @@ public static class MMC isoSector = rootMs.ToArray(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } @@ -2275,8 +2282,10 @@ public static class MMC isoSector = ngcdMs.ToArray(); iplTxt = Encoding.ASCII.GetString(isoSector); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + iplTxt = null; } @@ -2363,8 +2372,10 @@ public static class MMC { _ = Convert.ToUInt32(split[2], 16); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + correctNeoGeoCd = false; break; @@ -2414,8 +2425,10 @@ public static class MMC isoSector = vcdMs.ToArray(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } @@ -2528,8 +2541,10 @@ public static class MMC isoSector = pcdMs.ToArray(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } @@ -2638,8 +2653,10 @@ public static class MMC isoSector = ps1Ms.ToArray(); ps1Txt = Encoding.ASCII.GetString(isoSector); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + ps1Txt = null; } diff --git a/Aaru.Core/Remote.cs b/Aaru.Core/Remote.cs index aa782ead8..fa904d4c4 100644 --- a/Aaru.Core/Remote.cs +++ b/Aaru.Core/Remote.cs @@ -46,6 +46,7 @@ using Aaru.Database.Models; using Aaru.Dto; using Aaru.Logging; using Microsoft.EntityFrameworkCore; +using Sentry; using Spectre.Console; using CdOffset = Aaru.Database.Models.CdOffset; using Version = Aaru.CommonTypes.Metadata.Version; @@ -91,14 +92,16 @@ public static class Remote await reader.ReadToEndAsync(); data.Close(); } - catch(WebException) + catch(WebException ex) { // Can't connect to the server, do nothing + SentrySdk.CaptureException(ex); } - // ReSharper disable once RedundantCatchClause - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + #if DEBUG if(Debugger.IsAttached) throw; #endif @@ -179,8 +182,7 @@ public static class Remote if(!response.IsSuccessStatusCode) { - AaruLogging.Error(Localization.Core.Error_0_when_trying_to_get_updated_entities, - response.StatusCode); + AaruLogging.Error(Localization.Core.Error_0_when_trying_to_get_updated_entities, response.StatusCode); return; } diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index b46388b68..69afb11df 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -45,6 +45,7 @@ using Aaru.Filters; using Aaru.Helpers; using Aaru.Images; using Aaru.Logging; +using Sentry; using Directory = System.IO.Directory; using File = System.IO.File; using MediaType = Aaru.CommonTypes.Metadata.MediaType; @@ -506,8 +507,8 @@ public sealed partial class Sidecar if(errno != ErrorNumber.NoError) { AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, - tapePartition.FirstBlock + doneSectors)); + errno, + tapePartition.FirstBlock + doneSectors)); EndProgress2(); @@ -526,8 +527,8 @@ public sealed partial class Sidecar if(errno != ErrorNumber.NoError) { AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, - tapePartition.FirstBlock + doneSectors)); + errno, + tapePartition.FirstBlock + doneSectors)); EndProgress2(); @@ -606,8 +607,8 @@ public sealed partial class Sidecar if(errno != ErrorNumber.NoError) { AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, - tapeFile.FirstBlock + doneSectors)); + errno, + tapeFile.FirstBlock + doneSectors)); EndProgress2(); @@ -629,8 +630,8 @@ public sealed partial class Sidecar if(errno != ErrorNumber.NoError) { AaruLogging.Error(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, - tapeFile.FirstBlock + doneSectors)); + errno, + tapeFile.FirstBlock + doneSectors)); EndProgress2(); @@ -727,11 +728,9 @@ public sealed partial class Sidecar Statistics.AddFilesystem(fsMetadata.Type); } } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + catch(Exception ex) { - //AaruLogging.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); + SentrySdk.CaptureException(ex); } } @@ -789,11 +788,9 @@ public sealed partial class Sidecar Statistics.AddFilesystem(fsMetadata.Type); } } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + catch(Exception ex) { - //AaruLogging.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); + SentrySdk.CaptureException(ex); } } @@ -1046,18 +1043,16 @@ public sealed partial class Sidecar } else { - AaruLogging.Error(Localization.Core - .SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - scpImage.Header.end + 1, - image.Info.Cylinders); + AaruLogging.Error(Localization.Core.SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + scpImage.Header.end + 1, + image.Info.Cylinders); } } else { - AaruLogging.Error(Localization.Core - .SCP_image_do_not_same_number_heads_0_disk_image_1_ignoring, - 2, - image.Info.Heads); + AaruLogging.Error(Localization.Core.SCP_image_do_not_same_number_heads_0_disk_image_1_ignoring, + 2, + image.Info.Heads); } } } @@ -1158,17 +1153,16 @@ public sealed partial class Sidecar else { AaruLogging.Error(Localization.Core - .KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - kfImage.Info.Cylinders, - image.Info.Cylinders); + .KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + kfImage.Info.Cylinders, + image.Info.Cylinders); } } else { - AaruLogging.Error(Localization.Core - .KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring, - kfImage.Info.Heads, - image.Info.Heads); + AaruLogging.Error(Localization.Core.KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring, + kfImage.Info.Heads, + image.Info.Heads); } } } @@ -1249,18 +1243,16 @@ public sealed partial class Sidecar } else { - AaruLogging.Error(Localization.Core - .DiscFerret_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - dfiImage.Info.Cylinders, - image.Info.Cylinders); + AaruLogging.Error(Localization.Core.DiscFerret_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + dfiImage.Info.Cylinders, + image.Info.Cylinders); } } else { - AaruLogging.Error(Localization.Core - .DiscFerret_image_do_not_same_number_heads_0_disk_image_1_ignoring, - dfiImage.Info.Heads, - image.Info.Heads); + AaruLogging.Error(Localization.Core.DiscFerret_image_do_not_same_number_heads_0_disk_image_1_ignoring, + dfiImage.Info.Heads, + image.Info.Heads); } #endregion diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 338916d87..d00e3d03b 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -41,6 +41,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Decoders.CD; using Aaru.Decoders.DVD; +using Sentry; using DMI = Aaru.Decoders.Xbox.DMI; using Dump = Aaru.Core.Devices.Dumping.Dump; using Partition = Aaru.CommonTypes.Partition; @@ -222,8 +223,10 @@ public sealed partial class Sidecar List sessions = image.Sessions; sidecar.OpticalDiscs[0].Sessions = (uint)(sessions?.Count ?? 1); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + sidecar.OpticalDiscs[0].Sessions = 1; } @@ -568,11 +571,9 @@ public sealed partial class Sidecar _ => dskType }; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + catch(Exception ex) { - //AaruLogging.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); + SentrySdk.CaptureException(ex); } } @@ -646,11 +647,9 @@ public sealed partial class Sidecar _ => dskType }; } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + catch(Exception ex) { - //AaruLogging.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); + SentrySdk.CaptureException(ex); } } diff --git a/Aaru.Core/Statistics.cs b/Aaru.Core/Statistics.cs index e94a76e84..fa694f41e 100644 --- a/Aaru.Core/Statistics.cs +++ b/Aaru.Core/Statistics.cs @@ -46,6 +46,7 @@ using Aaru.Database.Models; using Aaru.Logging; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; +using Sentry; using Device = Aaru.Devices.Device; using MediaType = Aaru.CommonTypes.MediaType; using OperatingSystem = Aaru.Database.Models.OperatingSystem; @@ -300,18 +301,21 @@ public static class Statistics await ctx.SaveChangesAsync(); } - catch(WebException) + catch(WebException ex) { // Can't connect to the server, do nothing + SentrySdk.CaptureException(ex); } - catch(DbUpdateConcurrencyException) + catch(DbUpdateConcurrencyException ex) { // Ignore db concurrency errors + SentrySdk.CaptureException(ex); } - // ReSharper disable once RedundantCatchClause - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + #if DEBUG _submitStatsLock = false; diff --git a/Aaru.Decoders/Aaru.Decoders.csproj b/Aaru.Decoders/Aaru.Decoders.csproj index f6cc4c8c3..d0909320f 100644 --- a/Aaru.Decoders/Aaru.Decoders.csproj +++ b/Aaru.Decoders/Aaru.Decoders.csproj @@ -63,6 +63,9 @@ + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + ..\..\..\..\.nuget\packages\spectre.console\0.50.0\lib\net9.0\Spectre.Console.dll diff --git a/Aaru.Decoders/SCSI/MMC/Features.cs b/Aaru.Decoders/SCSI/MMC/Features.cs index a40852f77..7700d991f 100644 --- a/Aaru.Decoders/SCSI/MMC/Features.cs +++ b/Aaru.Decoders/SCSI/MMC/Features.cs @@ -37,6 +37,7 @@ using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Helpers; using Aaru.Localization; +using Sentry; // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedType.Global @@ -4209,12 +4210,10 @@ public static class Features sb.AppendFormat($"[slateblue1]{Localization.Drive_firmware_is_dated_0}[/]", $"[yellow3]{fwDate}[/]") .AppendLine(); } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body return sb.ToString(); } diff --git a/Aaru.Decoders/Sega/CD.cs b/Aaru.Decoders/Sega/CD.cs index b3a32aecf..817092640 100644 --- a/Aaru.Decoders/Sega/CD.cs +++ b/Aaru.Decoders/Sega/CD.cs @@ -37,6 +37,7 @@ using System.Runtime.InteropServices; using System.Text; using Aaru.Localization; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Decoders.Sega; @@ -61,12 +62,12 @@ public static class CD IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.volume_name = \"{0}\"", - Encoding.ASCII.GetString(ipbin.volume_name)); + "segacd_ipbin.volume_name = \"{0}\"", + Encoding.ASCII.GetString(ipbin.volume_name)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.system_name = \"{0}\"", - Encoding.ASCII.GetString(ipbin.system_name)); + "segacd_ipbin.system_name = \"{0}\"", + Encoding.ASCII.GetString(ipbin.system_name)); AaruLogging.Debug(MODULE_NAME, "segacd_ipbin.volume_version = \"{0:X}\"", ipbin.volume_version); @@ -89,36 +90,36 @@ public static class CD AaruLogging.Debug(MODULE_NAME, "segacd_ipbin.sp_work_ram_size = {0}", ipbin.sp_work_ram_size); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.release_date = \"{0}\"", - Encoding.ASCII.GetString(ipbin.release_date)); + "segacd_ipbin.release_date = \"{0}\"", + Encoding.ASCII.GetString(ipbin.release_date)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.release_date2 = \"{0}\"", - Encoding.ASCII.GetString(ipbin.release_date2)); + "segacd_ipbin.release_date2 = \"{0}\"", + Encoding.ASCII.GetString(ipbin.release_date2)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.developer_code = \"{0}\"", - Encoding.ASCII.GetString(ipbin.developer_code)); + "segacd_ipbin.developer_code = \"{0}\"", + Encoding.ASCII.GetString(ipbin.developer_code)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.domestic_title = \"{0}\"", - Encoding.ASCII.GetString(ipbin.domestic_title)); + "segacd_ipbin.domestic_title = \"{0}\"", + Encoding.ASCII.GetString(ipbin.domestic_title)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.overseas_title = \"{0}\"", - Encoding.ASCII.GetString(ipbin.overseas_title)); + "segacd_ipbin.overseas_title = \"{0}\"", + Encoding.ASCII.GetString(ipbin.overseas_title)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.product_code = \"{0}\"", - Encoding.ASCII.GetString(ipbin.product_code)); + "segacd_ipbin.product_code = \"{0}\"", + Encoding.ASCII.GetString(ipbin.product_code)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.peripherals = \"{0}\"", - Encoding.ASCII.GetString(ipbin.peripherals)); + "segacd_ipbin.peripherals = \"{0}\"", + Encoding.ASCII.GetString(ipbin.peripherals)); AaruLogging.Debug(MODULE_NAME, - "segacd_ipbin.region_codes = \"{0}\"", - Encoding.ASCII.GetString(ipbin.region_codes)); + "segacd_ipbin.region_codes = \"{0}\"", + Encoding.ASCII.GetString(ipbin.region_codes)); string id = Encoding.ASCII.GetString(ipbin.SegaHardwareID); @@ -154,12 +155,10 @@ public static class CD { ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date2), "yyyy.MMM", provider); } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } /* diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj index 5d4ce8e35..9f8d81925 100644 --- a/Aaru.Devices/Aaru.Devices.csproj +++ b/Aaru.Devices/Aaru.Devices.csproj @@ -49,4 +49,9 @@ Localization.Designer.cs + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index 4c0876c3b..175f7d51f 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -39,6 +39,7 @@ using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; using Aaru.Helpers; +using Sentry; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; namespace Aaru.Devices; @@ -65,8 +66,10 @@ public partial class Device { aaruUri = new Uri(devicePath); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + aaruUri = null; } diff --git a/Aaru.Devices/Device/List.cs b/Aaru.Devices/Device/List.cs index 015b86808..914de5ae2 100644 --- a/Aaru.Devices/Device/List.cs +++ b/Aaru.Devices/Device/List.cs @@ -34,6 +34,7 @@ using System; using System.Runtime.InteropServices; using Aaru.CommonTypes.Interop; using Aaru.Logging; +using Sentry; namespace Aaru.Devices; @@ -132,8 +133,11 @@ public partial class Device return remote.ListDevices(); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + + AaruLogging.Exception(ex, Localization.Error_connecting_to_host); AaruLogging.Error(Localization.Error_connecting_to_host); return []; diff --git a/Aaru.Devices/Linux/ListDevices.cs b/Aaru.Devices/Linux/ListDevices.cs index c52356f85..d6835212f 100644 --- a/Aaru.Devices/Linux/ListDevices.cs +++ b/Aaru.Devices/Linux/ListDevices.cs @@ -34,6 +34,7 @@ using System; using System.IO; using System.Runtime.Versioning; using System.Text; +using Sentry; namespace Aaru.Devices.Linux; @@ -58,12 +59,14 @@ static class ListDevices udev = Extern.udev_new(); hasUdev = udev != IntPtr.Zero; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + hasUdev = false; } - for(var i = 0; i < sysdevs.Length; i++) + for(int i = 0; i < sysdevs.Length; i++) { devices[i] = new DeviceInfo { diff --git a/Aaru.Devices/Remote/Device.cs b/Aaru.Devices/Remote/Device.cs index 5c53649b0..ca9b4cc82 100644 --- a/Aaru.Devices/Remote/Device.cs +++ b/Aaru.Devices/Remote/Device.cs @@ -36,6 +36,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SecureDigital; +using Sentry; namespace Aaru.Devices.Remote; @@ -113,6 +114,8 @@ public sealed partial class Device : Devices.Device } catch(Exception ex) { + SentrySdk.CaptureException(ex); + if(ex is SocketException sockEx) errno = (ErrorNumber)(-1 * sockEx.ErrorCode); else diff --git a/Aaru.Devices/Remote/Remote.cs b/Aaru.Devices/Remote/Remote.cs index 35b4fbd74..8e00f6d29 100644 --- a/Aaru.Devices/Remote/Remote.cs +++ b/Aaru.Devices/Remote/Remote.cs @@ -43,6 +43,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interop; using Aaru.Decoders.ATA; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; using Version = Aaru.CommonTypes.Interop.Version; @@ -259,9 +260,8 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAmIRoot) { - AaruLogging.Error(Localization - .Remote_IsRoot_Expected_Am_I_Root_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Remote_IsRoot_Expected_Am_I_Root_Response_Packet_got_packet_type_0, + hdr.packetType); return false; } @@ -297,9 +297,10 @@ public class Remote : IDisposable _socket.Shutdown(SocketShutdown.Both); _socket.Close(); } - catch(ObjectDisposedException) + catch(ObjectDisposedException ex) { // Ignore if already disposed + SentrySdk.CaptureException(ex); } } @@ -355,8 +356,8 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.Nop) { AaruLogging.Error(Localization - .Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, - hdr.packetType); + .Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, + hdr.packetType); return []; } @@ -474,9 +475,8 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.Nop) { - AaruLogging.Error(Localization - .Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, + hdr.packetType); lastError = -1; @@ -802,8 +802,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAtaLba28) { - AaruLogging.Error(Localization.Expected_ATA_LBA28_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_ATA_LBA28_Response_Packet_got_packet_type_0, hdr.packetType); return -1; } @@ -909,8 +908,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAtaLba48) { - AaruLogging.Error(Localization.Expected_ATA_LBA48_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_ATA_LBA48_Response_Packet_got_packet_type_0, hdr.packetType); return -1; } @@ -1103,8 +1101,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetType) { - AaruLogging.Error(Localization.Expected_Device_Type_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_Device_Type_Response_Packet_got_packet_type_0, hdr.packetType); return DeviceType.Unknown; } @@ -1182,8 +1179,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetSdhciRegisters) { - AaruLogging.Error(Localization.Expected_Device_Type_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_Device_Type_Response_Packet_got_packet_type_0, hdr.packetType); return false; } @@ -1308,8 +1304,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetUsbData) { - AaruLogging.Error(Localization.Expected_USB_Data_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_USB_Data_Response_Packet_got_packet_type_0, hdr.packetType); return false; } @@ -1400,8 +1395,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetFireWireData) { - AaruLogging.Error(Localization.Expected_FireWire_Data_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_FireWire_Data_Response_Packet_got_packet_type_0, hdr.packetType); return false; } @@ -1481,8 +1475,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetPcmciaData) { - AaruLogging.Error(Localization.Expected_PCMCIA_Data_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruLogging.Error(Localization.Expected_PCMCIA_Data_Response_Packet_got_packet_type_0, hdr.packetType); return false; } @@ -1550,9 +1543,10 @@ public class Remote : IDisposable { _socket.Send(buf, SocketFlags.None); } - catch(ObjectDisposedException) + catch(ObjectDisposedException ex) { // Ignore if already disposed + SentrySdk.CaptureException(ex); } } @@ -1657,7 +1651,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseMultiSdhci) { AaruLogging.Error(Localization.Expected_multi_MMC_SD_command_Response_Packet_got_packet_type_0, - hdr.packetType); + hdr.packetType); return -1; } @@ -1677,8 +1671,8 @@ public class Remote : IDisposable if(res.cmd_count != (ulong)commands.Length) { AaruLogging.Error(Localization.Expected_the_response_to_0_SD_MMC_commands_but_got_1_responses, - commands.Length, - res.cmd_count); + commands.Length, + res.cmd_count); return -1; } diff --git a/Aaru.Filesystems/APFS/Info.cs b/Aaru.Filesystems/APFS/Info.cs index 5bca26a19..40ad0731f 100644 --- a/Aaru.Filesystems/APFS/Info.cs +++ b/Aaru.Filesystems/APFS/Info.cs @@ -26,12 +26,14 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; +using Sentry; using Partition = Aaru.CommonTypes.Partition; namespace Aaru.Filesystems; @@ -58,8 +60,10 @@ public sealed partial class APFS { nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } @@ -86,8 +90,10 @@ public sealed partial class APFS { nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return; } diff --git a/Aaru.Filesystems/Aaru.Filesystems.csproj b/Aaru.Filesystems/Aaru.Filesystems.csproj index 66b23743c..f37f30f99 100644 --- a/Aaru.Filesystems/Aaru.Filesystems.csproj +++ b/Aaru.Filesystems/Aaru.Filesystems.csproj @@ -68,4 +68,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Filesystems/BTRFS/Info.cs b/Aaru.Filesystems/BTRFS/Info.cs index d8a2ab8d6..2b92d2f8d 100644 --- a/Aaru.Filesystems/BTRFS/Info.cs +++ b/Aaru.Filesystems/BTRFS/Info.cs @@ -30,12 +30,14 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Text; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Partition = Aaru.CommonTypes.Partition; namespace Aaru.Filesystems; @@ -66,8 +68,10 @@ public sealed partial class BTRFS { btrfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } diff --git a/Aaru.Filesystems/CPM/Definitions.cs b/Aaru.Filesystems/CPM/Definitions.cs index 7d73fbb24..d5ae7d6ad 100644 --- a/Aaru.Filesystems/CPM/Definitions.cs +++ b/Aaru.Filesystems/CPM/Definitions.cs @@ -37,6 +37,7 @@ using System.IO; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; +using Sentry; namespace Aaru.Filesystems; @@ -68,7 +69,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(var i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; + for(int i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; } if(def.sides != 2 || def.side2 != null) continue; @@ -80,14 +81,16 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(var i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; + for(int i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; } } return true; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } } diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index aa1703bc8..2f63a70b9 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -35,6 +35,7 @@ using System.Text; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; +using Sentry; namespace Aaru.Filesystems; @@ -106,19 +107,19 @@ public sealed partial class CPM { if(directory == null) return false; - var fileCount = 0; + int fileCount = 0; - for(var off = 0; off < directory.Length; off += 32) + for(int off = 0; off < directory.Length; off += 32) { DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(directory, off, 32); if((entry.statusUser & 0x7F) < 0x20) { - for(var f = 0; f < 8; f++) + for(int f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(var e = 0; e < 3; e++) + for(int e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; @@ -130,11 +131,11 @@ public sealed partial class CPM { case 0x20: { - for(var f = 0; f < 8; f++) + for(int f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(var e = 0; e < 3; e++) + for(int e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; @@ -160,8 +161,10 @@ public sealed partial class CPM return fileCount > 0; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } } diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index eaefe73a8..c9d545997 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -40,6 +40,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Partition = Aaru.CommonTypes.Partition; namespace Aaru.Filesystems; @@ -971,8 +972,8 @@ public sealed partial class CPM 0) { AaruLogging.Debug(MODULE_NAME, - Localization - .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); + Localization + .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); continue; } @@ -982,17 +983,16 @@ public sealed partial class CPM 0) { AaruLogging.Debug(MODULE_NAME, - Localization - .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); + Localization + .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); continue; } else { AaruLogging.Debug(MODULE_NAME, - Localization - .Unknown_order_type_0_not_proceeding_with_this_definition, - def.order); + Localization.Unknown_order_type_0_not_proceeding_with_this_definition, + def.order); continue; } @@ -1019,8 +1019,8 @@ public sealed partial class CPM if(def.evenOdd) { AaruLogging.Debug(MODULE_NAME, - Localization - .Definition_contains_EVEN_ODD_field_with_unknown_meaning_detection_may_be_wrong); + Localization + .Definition_contains_EVEN_ODD_field_with_unknown_meaning_detection_may_be_wrong); } // Complement of the directory bytes if needed @@ -1033,8 +1033,8 @@ public sealed partial class CPM if(CheckDir(directory)) { AaruLogging.Debug(MODULE_NAME, - Localization.Definition_0_has_a_correct_directory, - def.comment); + Localization.Definition_0_has_a_correct_directory, + def.comment); // Build a Disc Parameter Block _workingDefinition = def; @@ -1127,8 +1127,10 @@ public sealed partial class CPM return false; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + //throw ex; return false; } diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs index 64cf134c4..1e82f9bc6 100644 --- a/Aaru.Filesystems/FFS/Info.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -35,6 +35,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Partition = Aaru.CommonTypes.Partition; namespace Aaru.Filesystems; @@ -90,8 +91,10 @@ public sealed partial class FFSPlugin return false; } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } } diff --git a/Aaru.Filesystems/ISO9660/Date.cs b/Aaru.Filesystems/ISO9660/Date.cs index d8271e6b4..4c4372d7c 100644 --- a/Aaru.Filesystems/ISO9660/Date.cs +++ b/Aaru.Filesystems/ISO9660/Date.cs @@ -29,6 +29,7 @@ using System; using Aaru.Helpers; +using Sentry; namespace Aaru.Filesystems; @@ -59,8 +60,10 @@ public sealed partial class ISO9660 return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT")); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + // ISO says timestamp can be unspecified return null; } @@ -80,8 +83,10 @@ public sealed partial class ISO9660 return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT")); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + // ISO says timestamp can be unspecified, suppose same for High Sierra return null; } diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 8223f001e..d5fef03b1 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -40,6 +40,7 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Decoders.Sega; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using FileSystemInfo = Aaru.CommonTypes.Structs.FileSystemInfo; using Partition = Aaru.CommonTypes.Partition; @@ -208,7 +209,7 @@ public sealed partial class ISO9660 else { AaruLogging.Debug(MODULE_NAME, - Localization.Found_unknown_supplementary_volume_descriptor); + Localization.Found_unknown_supplementary_volume_descriptor); } } @@ -352,8 +353,8 @@ public sealed partial class ISO9660 if(_pathTable?.Length > 1 && rootLocation != _pathTable[0].Extent) { AaruLogging.Debug(MODULE_NAME, - Localization - .Path_table_and_PVD_do_not_point_to_the_same_location_for_the_root_directory); + Localization + .Path_table_and_PVD_do_not_point_to_the_same_location_for_the_root_directory); errno = ReadSector(rootLocation, out byte[] firstRootSector); @@ -379,8 +380,7 @@ public sealed partial class ISO9660 if(pvdWrongRoot) { AaruLogging.Debug(MODULE_NAME, - Localization - .PVD_does_not_point_to_correct_root_directory_checking_path_table); + Localization.PVD_does_not_point_to_correct_root_directory_checking_path_table); bool pathTableWrongRoot = false; @@ -462,8 +462,10 @@ public sealed partial class ISO9660 { ReadSingleExtent(rootSize, rootLocation, out byte[] _); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return ErrorNumber.InvalidArgument; } diff --git a/Aaru.Filesystems/PCFX/Info.cs b/Aaru.Filesystems/PCFX/Info.cs index 826bb10d7..6b654c516 100644 --- a/Aaru.Filesystems/PCFX/Info.cs +++ b/Aaru.Filesystems/PCFX/Info.cs @@ -36,6 +36,7 @@ using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; +using Sentry; using Partition = Aaru.CommonTypes.Partition; namespace Aaru.Filesystems; @@ -83,13 +84,15 @@ public sealed partial class PCFX try { date = encoding.GetString(header.date); - var year = int.Parse(date[..4]); - var month = int.Parse(date.Substring(4, 2)); - var day = int.Parse(date.Substring(6, 2)); + int year = int.Parse(date[..4]); + int month = int.Parse(date.Substring(4, 2)); + int day = int.Parse(date.Substring(6, 2)); dateTime = new DateTime(year, month, day); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + date = null; } diff --git a/Aaru.Gui/Aaru.Gui.csproj b/Aaru.Gui/Aaru.Gui.csproj index b6ac24c57..903e05def 100644 --- a/Aaru.Gui/Aaru.Gui.csproj +++ b/Aaru.Gui/Aaru.Gui.csproj @@ -427,4 +427,9 @@ LICENSE + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Gui/Main.cs b/Aaru.Gui/Main.cs index 4f5d2d63e..fdc725e52 100644 --- a/Aaru.Gui/Main.cs +++ b/Aaru.Gui/Main.cs @@ -26,10 +26,12 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ +using System; using System.Text; using Avalonia; using Avalonia.Dialogs; using Avalonia.ReactiveUI; +using Sentry; namespace Aaru.Gui; @@ -37,9 +39,42 @@ public static class Main { public static int Start(string[] args) { - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + SentrySdk.Init(options => + { + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = "https://153a04fb97b78bb57a8013b8b30db04f@sentry.claunia.com/8"; - return BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + // When debug is enabled, the Sentry client will emit detailed debugging information to the console. + // This might be helpful, or might interfere with the normal operation of your application. + // We enable it here for demonstration purposes when first trying Sentry. + // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. + //options.Debug = true; + + // This option is recommended. It enables Sentry's "Release Health" feature. + options.AutoSessionTracking = true; + + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production. + options.TracesSampleRate = 1.0; + + options.IsGlobalModeEnabled = true; + }); + + try + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + + return BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + } + catch(Exception ex) + { + SentrySdk.CaptureException(ex); + } + + return -1; } // Avalonia configuration, don't remove; also used by visual designer. diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 724e2e616..0b8d5b4e3 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -56,6 +56,7 @@ using Avalonia.Platform; using Humanizer; using Humanizer.Bytes; using ReactiveUI; +using Sentry; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; using Session = Aaru.CommonTypes.Structs.Session; using Track = Aaru.CommonTypes.Structs.Track; @@ -313,7 +314,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != toc.Length) { - var tmp = new byte[toc.Length + 2]; + byte[] tmp = new byte[toc.Length + 2]; Array.Copy(toc, 0, tmp, 2, toc.Length); tmp[0] = (byte)((toc.Length & 0xFF00) >> 8); tmp[1] = (byte)(toc.Length & 0xFF); @@ -334,7 +335,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != fullToc.Length) { - var tmp = new byte[fullToc.Length + 2]; + byte[] tmp = new byte[fullToc.Length + 2]; Array.Copy(fullToc, 0, tmp, 2, fullToc.Length); tmp[0] = (byte)((fullToc.Length & 0xFF00) >> 8); tmp[1] = (byte)(fullToc.Length & 0xFF); @@ -355,7 +356,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != pma.Length) { - var tmp = new byte[pma.Length + 2]; + byte[] tmp = new byte[pma.Length + 2]; Array.Copy(pma, 0, tmp, 2, pma.Length); tmp[0] = (byte)((pma.Length & 0xFF00) >> 8); tmp[1] = (byte)(pma.Length & 0xFF); @@ -374,7 +375,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 4 != atip.Length) { - var tmp = new byte[atip.Length + 4]; + byte[] tmp = new byte[atip.Length + 4]; Array.Copy(atip, 0, tmp, 4, atip.Length); tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24); tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16); @@ -397,7 +398,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 4 != cdtext.Length) { - var tmp = new byte[cdtext.Length + 4]; + byte[] tmp = new byte[cdtext.Length + 4]; Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); @@ -697,9 +698,9 @@ public sealed class ImageInfoViewModel : ViewModelBase foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session); } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try @@ -708,9 +709,10 @@ public sealed class ImageInfoViewModel : ViewModelBase foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track); } - catch + catch(Exception ex) { // ignored + SentrySdk.CaptureException(ex); } } diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index 0e604223b..3ce3cd737 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -51,6 +51,7 @@ using JetBrains.Annotations; using MsBox.Avalonia; using MsBox.Avalonia.Enums; using ReactiveUI; +using Sentry; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; namespace Aaru.Gui.ViewModels.Panels; @@ -89,10 +90,9 @@ public sealed class SubdirectoryViewModel if(errno != ErrorNumber.NoError) { - AaruLogging - .Error(string.Format(UI.Error_0_trying_to_get_information_about_filesystem_entry_named_1, - errno, - dirent)); + AaruLogging.Error(string.Format(UI.Error_0_trying_to_get_information_about_filesystem_entry_named_1, + errno, + dirent)); continue; } @@ -359,34 +359,33 @@ public sealed class SubdirectoryViewModel fs.Write(outBuf, 0, outBuf.Length); fs.Close(); var fi = new FileInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body + try { if(file.Stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = file.Stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(file.Stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = file.Stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(file.Stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = file.Stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } catch(IOException) { diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index 3ff47940b..bafeaa3f8 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -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; diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index 255f9b16b..c0ac40f15 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -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); } diff --git a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs index ddc429d7d..d99860ade 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs @@ -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(() => { diff --git a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs index ec60fe2ee..53ef48e7e 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs @@ -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, diff --git a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs index c21076f9c..0947f9f96 100644 --- a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs @@ -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; } diff --git a/Aaru.Images/Aaru.Images.csproj b/Aaru.Images/Aaru.Images.csproj index 035936573..50d59d23d 100644 --- a/Aaru.Images/Aaru.Images.csproj +++ b/Aaru.Images/Aaru.Images.csproj @@ -63,4 +63,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index 4b0e33106..1aaa66290 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -49,6 +49,7 @@ using Aaru.Filters; using Aaru.Helpers; using Aaru.Helpers.IO; using Aaru.Logging; +using Sentry; using DMI = Aaru.Decoders.Xbox.DMI; using Sector = Aaru.Decoders.CD.Sector; using Session = Aaru.CommonTypes.Structs.Session; @@ -104,9 +105,7 @@ public sealed partial class BlindWrite5 for(int i = 0; i < _header.unknown6.Length; i++) AaruLogging.Debug(MODULE_NAME, "header.unknown6[{1}] = 0x{0:X2}", _header.unknown6[i], i); - AaruLogging.Debug(MODULE_NAME, - "header.manufacturer = {0}", - StringHandlers.CToString(_header.manufacturer)); + AaruLogging.Debug(MODULE_NAME, "header.manufacturer = {0}", StringHandlers.CToString(_header.manufacturer)); AaruLogging.Debug(MODULE_NAME, "header.product = {0}", StringHandlers.CToString(_header.product)); @@ -131,11 +130,7 @@ public sealed partial class BlindWrite5 var decoded2A = ModePage_2A.Decode(_mode2A); if(decoded2A is not null) - { - AaruLogging.Debug(MODULE_NAME, - Localization.mode_page_2A_0, - Modes.PrettifyModePage_2A(decoded2A)); - } + AaruLogging.Debug(MODULE_NAME, Localization.mode_page_2A_0, Modes.PrettifyModePage_2A(decoded2A)); else _mode2A = null; } @@ -231,8 +226,8 @@ public sealed partial class BlindWrite5 stream.EnsureRead(_discInformation, 0, _discInformation.Length); AaruLogging.Debug(MODULE_NAME, - Localization.Disc_information_0, - PrintHex.ByteArrayToHexArrayString(_discInformation, 40)); + Localization.Disc_information_0, + PrintHex.ByteArrayToHexArrayString(_discInformation, 40)); } else _discInformation = null; @@ -345,160 +340,160 @@ public sealed partial class BlindWrite5 } AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].type = {2}", - ses, - tSeq, - session.Tracks[tSeq].type); + "session[{0}].track[{1}].type = {2}", + ses, + tSeq, + session.Tracks[tSeq].type); for(int i = 0; i < session.Tracks[tSeq].unknown1.Length; i++) { AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", - ses, - tSeq, - i, - session.Tracks[tSeq].unknown1[i]); + "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown1[i]); } AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown2 = 0x{2:X8}", - ses, - tSeq, - session.Tracks[tSeq].unknown2); + "session[{0}].track[{1}].unknown2 = 0x{2:X8}", + ses, + tSeq, + session.Tracks[tSeq].unknown2); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].subchannel = {2}", - ses, - tSeq, - session.Tracks[tSeq].subchannel); + "session[{0}].track[{1}].subchannel = {2}", + ses, + tSeq, + session.Tracks[tSeq].subchannel); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown3 = 0x{2:X2}", - ses, - tSeq, - session.Tracks[tSeq].unknown3); + "session[{0}].track[{1}].unknown3 = 0x{2:X2}", + ses, + tSeq, + session.Tracks[tSeq].unknown3); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].ctl = {2}", - ses, - tSeq, - session.Tracks[tSeq].ctl); + "session[{0}].track[{1}].ctl = {2}", + ses, + tSeq, + session.Tracks[tSeq].ctl); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].adr = {2}", - ses, - tSeq, - session.Tracks[tSeq].adr); + "session[{0}].track[{1}].adr = {2}", + ses, + tSeq, + session.Tracks[tSeq].adr); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].point = {2}", - ses, - tSeq, - session.Tracks[tSeq].point); + "session[{0}].track[{1}].point = {2}", + ses, + tSeq, + session.Tracks[tSeq].point); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown4 = 0x{2:X2}", - ses, - tSeq, - session.Tracks[tSeq].tno); + "session[{0}].track[{1}].unknown4 = 0x{2:X2}", + ses, + tSeq, + session.Tracks[tSeq].tno); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].min = {2}", - ses, - tSeq, - session.Tracks[tSeq].min); + "session[{0}].track[{1}].min = {2}", + ses, + tSeq, + session.Tracks[tSeq].min); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].sec = {2}", - ses, - tSeq, - session.Tracks[tSeq].sec); + "session[{0}].track[{1}].sec = {2}", + ses, + tSeq, + session.Tracks[tSeq].sec); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].frame = {2}", - ses, - tSeq, - session.Tracks[tSeq].frame); + "session[{0}].track[{1}].frame = {2}", + ses, + tSeq, + session.Tracks[tSeq].frame); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].zero = {2}", - ses, - tSeq, - session.Tracks[tSeq].zero); + "session[{0}].track[{1}].zero = {2}", + ses, + tSeq, + session.Tracks[tSeq].zero); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].pmin = {2}", - ses, - tSeq, - session.Tracks[tSeq].pmin); + "session[{0}].track[{1}].pmin = {2}", + ses, + tSeq, + session.Tracks[tSeq].pmin); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].psec = {2}", - ses, - tSeq, - session.Tracks[tSeq].psec); + "session[{0}].track[{1}].psec = {2}", + ses, + tSeq, + session.Tracks[tSeq].psec); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].pframe = {2}", - ses, - tSeq, - session.Tracks[tSeq].pframe); + "session[{0}].track[{1}].pframe = {2}", + ses, + tSeq, + session.Tracks[tSeq].pframe); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown5 = 0x{2:X2}", - ses, - tSeq, - session.Tracks[tSeq].unknown5); + "session[{0}].track[{1}].unknown5 = 0x{2:X2}", + ses, + tSeq, + session.Tracks[tSeq].unknown5); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].pregap = {2}", - ses, - tSeq, - session.Tracks[tSeq].pregap); + "session[{0}].track[{1}].pregap = {2}", + ses, + tSeq, + session.Tracks[tSeq].pregap); for(int i = 0; i < session.Tracks[tSeq].unknown6.Length; i++) { AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", - ses, - tSeq, - i, - session.Tracks[tSeq].unknown6[i]); + "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown6[i]); } AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].startLba = {2}", - ses, - tSeq, - session.Tracks[tSeq].startLba); + "session[{0}].track[{1}].startLba = {2}", + ses, + tSeq, + session.Tracks[tSeq].startLba); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].sectors = {2}", - ses, - tSeq, - session.Tracks[tSeq].sectors); + "session[{0}].track[{1}].sectors = {2}", + ses, + tSeq, + session.Tracks[tSeq].sectors); for(int i = 0; i < session.Tracks[tSeq].unknown7.Length; i++) { AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", - ses, - tSeq, - i, - session.Tracks[tSeq].unknown7[i]); + "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown7[i]); } AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].session = {2}", - ses, - tSeq, - session.Tracks[tSeq].session); + "session[{0}].track[{1}].session = {2}", + ses, + tSeq, + session.Tracks[tSeq].session); AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown8 = 0x{2:X4}", - ses, - tSeq, - session.Tracks[tSeq].unknown8); + "session[{0}].track[{1}].unknown8 = 0x{2:X4}", + ses, + tSeq, + session.Tracks[tSeq].unknown8); if(session.Tracks[tSeq].type is TrackType.Dvd or TrackType.NotData) continue; @@ -506,11 +501,11 @@ public sealed partial class BlindWrite5 for(int i = 0; i < session.Tracks[tSeq].unknown9.Length; i++) { AaruLogging.Debug(MODULE_NAME, - "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", - ses, - tSeq, - i, - session.Tracks[tSeq].unknown9[i]); + "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown9[i]); } } } @@ -533,7 +528,7 @@ public sealed partial class BlindWrite5 else { AaruLogging.Error(Localization - .BlindWrite5_image_ends_after_expected_position_Probably_new_version_with_different_data_Errors_may_occur); + .BlindWrite5_image_ends_after_expected_position_Probably_new_version_with_different_data_Errors_may_occur); } _filePaths = []; @@ -683,8 +678,7 @@ public sealed partial class BlindWrite5 break; default: - AaruLogging.Error(Localization.BlindWrite5_found_unknown_subchannel_size_0, - sectorSize - 2352); + AaruLogging.Error(Localization.BlindWrite5_found_unknown_subchannel_size_0, sectorSize - 2352); return ErrorNumber.NotSupported; } @@ -1044,8 +1038,10 @@ public sealed partial class BlindWrite5 splitStream.AddRange(basePath, $"{filename}.{extension}"); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); + AaruLogging.Exception(ex, Localization.Could_not_find_image_for_track_0, trk.point); AaruLogging.Error(Localization.Could_not_find_image_for_track_0, trk.point); return ErrorNumber.NoSuchFile; diff --git a/Aaru.Images/ByteAddressable/Nintendo64.cs b/Aaru.Images/ByteAddressable/Nintendo64.cs index 1a6bc10da..6af4577bf 100644 --- a/Aaru.Images/ByteAddressable/Nintendo64.cs +++ b/Aaru.Images/ByteAddressable/Nintendo64.cs @@ -43,6 +43,7 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Images; @@ -212,8 +213,9 @@ public class Nintendo64 : IByteAddressableImage { encoding = Encoding.GetEncoding("shift_jis"); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); encoding = Encoding.ASCII; } diff --git a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs index 67d30f28c..b3c55d880 100644 --- a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs +++ b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs @@ -43,6 +43,7 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Images; @@ -231,8 +232,9 @@ public class SegaMegaDrive : IByteAddressableImage { encoding = Encoding.GetEncoding("shift_jis"); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); encoding = Encoding.ASCII; } diff --git a/Aaru.Images/ByteAddressable/SuperNintendo.cs b/Aaru.Images/ByteAddressable/SuperNintendo.cs index 691d970bb..98a8757df 100644 --- a/Aaru.Images/ByteAddressable/SuperNintendo.cs +++ b/Aaru.Images/ByteAddressable/SuperNintendo.cs @@ -11,6 +11,7 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Images; @@ -162,8 +163,9 @@ public class SuperNintendo : IByteAddressableImage { encoding = Encoding.GetEncoding("shift_jis"); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); encoding = Encoding.ASCII; } diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index 7baa4f319..6872ee5f8 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -41,6 +41,7 @@ using Aaru.Helpers; using Aaru.Logging; using Claunia.Encoding; using Claunia.RsrcFork; +using Sentry; using Version = Resources.Version; namespace Aaru.Images; @@ -247,12 +248,15 @@ public sealed partial class Dart } } } - catch(InvalidCastException) {} + catch(InvalidCastException ex) + { + SentrySdk.CaptureException(ex); + } AaruLogging.Debug(MODULE_NAME, - Localization.Image_application_0_version_1, - _imageInfo.Application, - _imageInfo.ApplicationVersion); + Localization.Image_application_0_version_1, + _imageInfo.Application, + _imageInfo.ApplicationVersion); _imageInfo.Sectors = (ulong)(header.srcSize * 2); _imageInfo.CreationTime = imageFilter.CreationTime; diff --git a/Aaru.Images/DiskCopy42/Read.cs b/Aaru.Images/DiskCopy42/Read.cs index e77560423..333473892 100644 --- a/Aaru.Images/DiskCopy42/Read.cs +++ b/Aaru.Images/DiskCopy42/Read.cs @@ -40,6 +40,7 @@ using Aaru.Helpers; using Aaru.Logging; using Claunia.Encoding; using Claunia.RsrcFork; +using Sentry; using Version = Resources.Version; namespace Aaru.Images; @@ -121,9 +122,7 @@ public sealed partial class DiskCopy42 header.FmtByte != kFmtNotStandard && header.FmtByte != kMacOSXFmtByte) { - AaruLogging.Debug(MODULE_NAME, - Localization.Unknown_tmp_header_fmtByte_equals_0_value, - header.FmtByte); + AaruLogging.Debug(MODULE_NAME, Localization.Unknown_tmp_header_fmtByte_equals_0_value, header.FmtByte); return ErrorNumber.NotSupported; } @@ -215,8 +214,7 @@ public sealed partial class DiskCopy42 } else { - AaruLogging.Debug(MODULE_NAME, - Localization.Lisa_Twiggy_detected_reversing_second_half_of_disk); + AaruLogging.Debug(MODULE_NAME, Localization.Lisa_Twiggy_detected_reversing_second_half_of_disk); Array.Copy(data, 0, twiggyCache, 0, header.DataSize / 2); Array.Copy(tags, 0, twiggyCacheTags, 0, header.TagSize / 2); @@ -318,12 +316,15 @@ public sealed partial class DiskCopy42 } } } - catch(InvalidCastException) {} + catch(InvalidCastException ex) + { + SentrySdk.CaptureException(ex); + } AaruLogging.Debug(MODULE_NAME, - Localization.Image_application_0_version_1, - imageInfo.Application, - imageInfo.ApplicationVersion); + Localization.Image_application_0_version_1, + imageInfo.Application, + imageInfo.ApplicationVersion); imageInfo.MetadataMediaType = MetadataMediaType.BlockMedia; AaruLogging.Verbose(Localization.DiskCopy_4_2_image_contains_a_disk_of_type_0, imageInfo.MediaType); diff --git a/Aaru.Images/Nero/Read.cs b/Aaru.Images/Nero/Read.cs index 7256c1600..a9e8bc156 100644 --- a/Aaru.Images/Nero/Read.cs +++ b/Aaru.Images/Nero/Read.cs @@ -42,6 +42,7 @@ using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; using Aaru.Helpers; using Aaru.Logging; +using Sentry; namespace Aaru.Images; @@ -74,16 +75,16 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, "imageStream.Length = {0}", _imageStream.Length); AaruLogging.Debug(MODULE_NAME, - "footerV1.ChunkID = 0x{0:X8} (\"{1}\")", - footerV1.ChunkId, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV1.ChunkId))); + "footerV1.ChunkID = 0x{0:X8} (\"{1}\")", + footerV1.ChunkId, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV1.ChunkId))); AaruLogging.Debug(MODULE_NAME, "footerV1.FirstChunkOffset = {0}", footerV1.FirstChunkOffset); AaruLogging.Debug(MODULE_NAME, - "footerV2.ChunkID = 0x{0:X8} (\"{1}\")", - footerV2.ChunkId, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV2.ChunkId))); + "footerV2.ChunkID = 0x{0:X8} (\"{1}\")", + footerV2.ChunkId, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV2.ChunkId))); AaruLogging.Debug(MODULE_NAME, "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset); @@ -129,9 +130,9 @@ public sealed partial class Nero uint chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); AaruLogging.Debug(MODULE_NAME, - "ChunkID = 0x{0:X8} (\"{1}\")", - chunkId, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); + "ChunkID = 0x{0:X8} (\"{1}\")", + chunkId, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); AaruLogging.Debug(MODULE_NAME, "ChunkLength = {0}", chunkLength); @@ -139,9 +140,7 @@ public sealed partial class Nero { case NERO_CUE_V1: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_CUES_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_CUES_chunk_parsing_0_bytes, chunkLength); var newCuesheetV1 = new CuesheetV1 { @@ -167,40 +166,25 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Cuesheet_entry_0, i / 8 + 1); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1:X2}", - i / 8 + 1, - entry.Mode); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Mode = {1:X2}", i / 8 + 1, entry.Mode); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].TrackNumber = {1:X2}", - i / 8 + 1, - entry.TrackNumber); + "\t _entry[{0}].TrackNumber = {1:X2}", + i / 8 + 1, + entry.TrackNumber); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].IndexNumber = {1:X2}", - i / 8 + 1, - entry.IndexNumber); + "\t _entry[{0}].IndexNumber = {1:X2}", + i / 8 + 1, + entry.IndexNumber); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Dummy = {1:X4}", - i / 8 + 1, - entry.Dummy); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Dummy = {1:X4}", i / 8 + 1, entry.Dummy); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Minute = {1:X2}", - i / 8 + 1, - entry.Minute); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Minute = {1:X2}", i / 8 + 1, entry.Minute); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Second = {1:X2}", - i / 8 + 1, - entry.Second); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Second = {1:X2}", i / 8 + 1, entry.Second); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Frame = {1:X2}", - i / 8 + 1, - entry.Frame); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Frame = {1:X2}", i / 8 + 1, entry.Frame); newCuesheetV1.Entries.Add(entry); } @@ -215,9 +199,7 @@ public sealed partial class Nero case NERO_CUE_V2: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_CUEX_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_CUEX_chunk_parsing_0_bytes, chunkLength); var newCuesheetV2 = new CuesheetV2 { @@ -240,30 +222,21 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Cuesheet_entry_0, i / 8 + 1); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = 0x{1:X2}", - i / 8 + 1, - entry.Mode); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Mode = 0x{1:X2}", i / 8 + 1, entry.Mode); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].TrackNumber = {1:X2}", - i / 8 + 1, - entry.TrackNumber); + "\t _entry[{0}].TrackNumber = {1:X2}", + i / 8 + 1, + entry.TrackNumber); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].IndexNumber = {1:X2}", - i / 8 + 1, - entry.IndexNumber); + "\t _entry[{0}].IndexNumber = {1:X2}", + i / 8 + 1, + entry.IndexNumber); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Dummy = {1:X2}", - i / 8 + 1, - entry.Dummy); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Dummy = {1:X2}", i / 8 + 1, entry.Dummy); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].LBAStart = {1}", - i / 8 + 1, - entry.LbaStart); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].LBAStart = {1}", i / 8 + 1, entry.LbaStart); newCuesheetV2.Entries.Add(entry); } @@ -278,9 +251,7 @@ public sealed partial class Nero case NERO_DAO_V1: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_DAOI_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_DAOI_chunk_parsing_0_bytes, chunkLength); _neroDaov1 = new DaoV1 { @@ -298,13 +269,11 @@ public sealed partial class Nero _neroDaov1.LastTrack = tmpBuffer[21]; _neroDaov1.Tracks = []; - AaruLogging.Debug(MODULE_NAME, - "neroDAOV1.ChunkSizeLe = {0} bytes", - _neroDaov1.ChunkSizeLe); + AaruLogging.Debug(MODULE_NAME, "neroDAOV1.ChunkSizeLe = {0} bytes", _neroDaov1.ChunkSizeLe); AaruLogging.Debug(MODULE_NAME, - "neroDAOV1.UPC = \"{0}\"", - StringHandlers.CToString(_neroDaov1.Upc)); + "neroDAOV1.UPC = \"{0}\"", + StringHandlers.CToString(_neroDaov1.Upc)); AaruLogging.Debug(MODULE_NAME, "neroDAOV1.TocType = 0x{0:X4}", _neroDaov1.TocType); @@ -350,40 +319,34 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Disc_At_Once_entry_0, i / 32 + 1); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].ISRC = \"{1}\"", - i / 32 + 1, - StringHandlers.CToString(entry.Isrc)); + "\t _entry[{0}].ISRC = \"{1}\"", + i / 32 + 1, + StringHandlers.CToString(entry.Isrc)); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].SectorSize = {1}", - i / 32 + 1, - entry.SectorSize); + "\t _entry[{0}].SectorSize = {1}", + i / 32 + 1, + entry.SectorSize); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1} (0x{2:X4})", - i / 32 + 1, - (DaoMode)entry.Mode, - entry.Mode); + "\t _entry[{0}].Mode = {1} (0x{2:X4})", + i / 32 + 1, + (DaoMode)entry.Mode, + entry.Mode); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Unknown = 0x{1:X4}", - i / 32 + 1, - entry.Unknown); + "\t _entry[{0}].Unknown = 0x{1:X4}", + i / 32 + 1, + entry.Unknown); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Index0 = {1}", - i / 32 + 1, - entry.Index0); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Index1 = {1}", - i / 32 + 1, - entry.Index1); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].EndOfTrack = {1}", - i / 32 + 1, - entry.EndOfTrack); + "\t _entry[{0}].EndOfTrack = {1}", + i / 32 + 1, + entry.EndOfTrack); _neroDaov1.Tracks.Add(entry); @@ -413,9 +376,7 @@ public sealed partial class Nero case NERO_DAO_V2: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_DAOX_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_DAOX_chunk_parsing_0_bytes, chunkLength); _neroDaov2 = new DaoV2 { @@ -435,13 +396,11 @@ public sealed partial class Nero _upc = _neroDaov2.Upc; - AaruLogging.Debug(MODULE_NAME, - "neroDAOV2.ChunkSizeLe = {0} bytes", - _neroDaov2.ChunkSizeLe); + AaruLogging.Debug(MODULE_NAME, "neroDAOV2.ChunkSizeLe = {0} bytes", _neroDaov2.ChunkSizeLe); AaruLogging.Debug(MODULE_NAME, - "neroDAOV2.UPC = \"{0}\"", - StringHandlers.CToString(_neroDaov2.Upc)); + "neroDAOV2.UPC = \"{0}\"", + StringHandlers.CToString(_neroDaov2.Upc)); AaruLogging.Debug(MODULE_NAME, "neroDAOV2.TocType = 0x{0:X4}", _neroDaov2.TocType); @@ -485,40 +444,34 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Disc_At_Once_entry_0, i / 32 + 1); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].ISRC = \"{1}\"", - i / 32 + 1, - StringHandlers.CToString(entry.Isrc)); + "\t _entry[{0}].ISRC = \"{1}\"", + i / 32 + 1, + StringHandlers.CToString(entry.Isrc)); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].SectorSize = {1}", - i / 32 + 1, - entry.SectorSize); + "\t _entry[{0}].SectorSize = {1}", + i / 32 + 1, + entry.SectorSize); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1} (0x{2:X4})", - i / 32 + 1, - (DaoMode)entry.Mode, - entry.Mode); + "\t _entry[{0}].Mode = {1} (0x{2:X4})", + i / 32 + 1, + (DaoMode)entry.Mode, + entry.Mode); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Unknown = {1:X2}", - i / 32 + 1, - entry.Unknown); + "\t _entry[{0}].Unknown = {1:X2}", + i / 32 + 1, + entry.Unknown); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Index0 = {1}", - i / 32 + 1, - entry.Index0); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Index1 = {1}", - i / 32 + 1, - entry.Index1); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].EndOfTrack = {1}", - i / 32 + 1, - entry.EndOfTrack); + "\t _entry[{0}].EndOfTrack = {1}", + i / 32 + 1, + entry.EndOfTrack); _neroDaov2.Tracks.Add(entry); @@ -549,9 +502,7 @@ public sealed partial class Nero case NERO_CDTEXT: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_CDTX_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_CDTX_chunk_parsing_0_bytes, chunkLength); _cdtxt = new CdText { @@ -578,34 +529,31 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.CD_TEXT_entry_0, i / 18 + 1); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].PackType = 0x{1:X2}", - i / 18 + 1, - entry.PackType); + "\t _entry[{0}].PackType = 0x{1:X2}", + i / 18 + 1, + entry.PackType); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].TrackNumber = 0x{1:X2}", - i / 18 + 1, - entry.TrackNumber); + "\t _entry[{0}].TrackNumber = 0x{1:X2}", + i / 18 + 1, + entry.TrackNumber); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].PackNumber = 0x{1:X2}", - i / 18 + 1, - entry.PackNumber); + "\t _entry[{0}].PackNumber = 0x{1:X2}", + i / 18 + 1, + entry.PackNumber); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].BlockNumber = 0x{1:X2}", - i / 18 + 1, - entry.BlockNumber); + "\t _entry[{0}].BlockNumber = 0x{1:X2}", + i / 18 + 1, + entry.BlockNumber); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Text = \"{1}\"", - i / 18 + 1, - StringHandlers.CToString(entry.Text)); + "\t _entry[{0}].Text = \"{1}\"", + i / 18 + 1, + StringHandlers.CToString(entry.Text)); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].CRC = 0x{1:X4}", - i / 18 + 1, - entry.Crc); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].CRC = 0x{1:X4}", i / 18 + 1, entry.Crc); _cdtxt.Packs.Add(entry); } @@ -615,9 +563,7 @@ public sealed partial class Nero case NERO_TAO_V0: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_TINF_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_TINF_chunk_parsing_0_bytes, chunkLength); oldFormat = true; @@ -641,21 +587,18 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Track_at_Once_entry_0, i / 20 + 1); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Offset = {1}", - i / 20 + 1, - entry.Offset); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Offset = {1}", i / 20 + 1, entry.Offset); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Length = {1} bytes", - i / 20 + 1, - entry.Length); + "\t _entry[{0}].Length = {1} bytes", + i / 20 + 1, + entry.Length); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1} (0x{2:X4})", - i / 20 + 1, - (DaoMode)entry.Mode, - entry.Mode); + "\t _entry[{0}].Mode = {1} (0x{2:X4})", + i / 20 + 1, + (DaoMode)entry.Mode, + entry.Mode); _taoV0.Tracks.Add(entry); @@ -688,9 +631,7 @@ public sealed partial class Nero case NERO_TAO_V1: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_ETNF_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_ETNF_chunk_parsing_0_bytes, chunkLength); _taoV1 = new TaoV1 { @@ -714,31 +655,25 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Track_at_Once_entry_0, i / 20 + 1); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Offset = {1}", - i / 20 + 1, - entry.Offset); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Offset = {1}", i / 20 + 1, entry.Offset); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Length = {1} bytes", - i / 20 + 1, - entry.Length); + "\t _entry[{0}].Length = {1} bytes", + i / 20 + 1, + entry.Length); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1} (0x{2:X4})", - i / 20 + 1, - (DaoMode)entry.Mode, - entry.Mode); + "\t _entry[{0}].Mode = {1} (0x{2:X4})", + i / 20 + 1, + (DaoMode)entry.Mode, + entry.Mode); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].StartLBA = {1}", i / 20 + 1, entry.StartLba); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].StartLBA = {1}", - i / 20 + 1, - entry.StartLba); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Unknown = 0x{1:X4}", - i / 20 + 1, - entry.Unknown); + "\t _entry[{0}].Unknown = 0x{1:X4}", + i / 20 + 1, + entry.Unknown); _taoV1.Tracks.Add(entry); @@ -770,9 +705,7 @@ public sealed partial class Nero case NERO_TAO_V2: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_ETN2_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_ETN2_chunk_parsing_0_bytes, chunkLength); _taoV2 = new TaoV2 { @@ -797,36 +730,27 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, Localization.Track_at_Once_entry_0, i / 32 + 1); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Offset = {1}", - i / 32 + 1, - entry.Offset); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Offset = {1}", i / 32 + 1, entry.Offset); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Length = {1} bytes", - i / 32 + 1, - entry.Length); + "\t _entry[{0}].Length = {1} bytes", + i / 32 + 1, + entry.Length); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Mode = {1} (0x{2:X4})", - i / 32 + 1, - (DaoMode)entry.Mode, - entry.Mode); + "\t _entry[{0}].Mode = {1} (0x{2:X4})", + i / 32 + 1, + (DaoMode)entry.Mode, + entry.Mode); + + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].StartLBA = {1}", i / 32 + 1, entry.StartLba); AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].StartLBA = {1}", - i / 32 + 1, - entry.StartLba); + "\t _entry[{0}].Unknown = 0x{1:X4}", + i / 32 + 1, + entry.Unknown); - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Unknown = 0x{1:X4}", - i / 32 + 1, - entry.Unknown); - - AaruLogging.Debug(MODULE_NAME, - "\t _entry[{0}].Sectors = {1}", - i / 32 + 1, - entry.Sectors); + AaruLogging.Debug(MODULE_NAME, "\t _entry[{0}].Sectors = {1}", i / 32 + 1, entry.Sectors); _taoV2.Tracks.Add(entry); @@ -867,9 +791,7 @@ public sealed partial class Nero case NERO_SESSION: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_SINF_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_SINF_chunk_parsing_0_bytes, chunkLength); byte[] tmpBuffer = new byte[4]; _imageStream.EnsureRead(tmpBuffer, 0, 4); @@ -877,9 +799,9 @@ public sealed partial class Nero _neroSessions.Add(currentSession, sessionTracks); AaruLogging.Debug(MODULE_NAME, - "\t" + Localization.Session_0_has_1_tracks, - currentSession, - sessionTracks); + "\t" + Localization.Session_0_has_1_tracks, + currentSession, + sessionTracks); currentSession++; @@ -888,9 +810,7 @@ public sealed partial class Nero case NERO_DISC_TYPE: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_MTYP_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_MTYP_chunk_parsing_0_bytes, chunkLength); _mediaType = new MediaType { @@ -903,9 +823,9 @@ public sealed partial class Nero _mediaType.Type = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); AaruLogging.Debug(MODULE_NAME, - "\t" + Localization.Media_type_is_0_1, - (NeroMediaTypes)_mediaType.Type, - _mediaType.Type); + "\t" + Localization.Media_type_is_0_1, + (NeroMediaTypes)_mediaType.Type, + _mediaType.Type); _imageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)_mediaType.Type); @@ -914,9 +834,7 @@ public sealed partial class Nero case NERO_DISC_INFO: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_DINF_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_DINF_chunk_parsing_0_bytes, chunkLength); _discInfo = new DiscInformation { @@ -928,18 +846,14 @@ public sealed partial class Nero _imageStream.EnsureRead(tmpBuffer, 0, 4); _discInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); - AaruLogging.Debug(MODULE_NAME, - "\tneroDiscInfo.Unknown = 0x{0:X4} ({0})", - _discInfo.Unknown); + AaruLogging.Debug(MODULE_NAME, "\tneroDiscInfo.Unknown = 0x{0:X4} ({0})", _discInfo.Unknown); break; } case NERO_RELOCATION: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_RELO_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_RELO_chunk_parsing_0_bytes, chunkLength); _relo = new ReloChunk { @@ -958,9 +872,7 @@ public sealed partial class Nero case NERO_TOC: { - AaruLogging.Debug(MODULE_NAME, - Localization.Found_TOCT_chunk_parsing_0_bytes, - chunkLength); + AaruLogging.Debug(MODULE_NAME, Localization.Found_TOCT_chunk_parsing_0_bytes, chunkLength); _toc = new TocChunk { @@ -996,8 +908,8 @@ public sealed partial class Nero default: { AaruLogging.Debug(MODULE_NAME, - Localization.Unknown_chunk_ID_0_skipping, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); + Localization.Unknown_chunk_ID_0_skipping, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); _imageStream.Seek(chunkLength, SeekOrigin.Current); @@ -1006,8 +918,7 @@ public sealed partial class Nero } } - if(corruptedTrackMode) - AaruLogging.Error(Localization.Inconsistent_track_mode_and_track_sector_size_found); + if(corruptedTrackMode) AaruLogging.Error(Localization.Inconsistent_track_mode_and_track_sector_size_found); _imageInfo.HasPartitions = true; _imageInfo.HasSessions = true; @@ -1072,11 +983,9 @@ public sealed partial class Nero { if(neroTrack.Offset >= (_imageNewFormat ? footerV2.FirstChunkOffset : footerV1.FirstChunkOffset)) { - AaruLogging.Error(Localization - .This_image_contains_a_track_that_is_set_to_start_outside_the_file); + AaruLogging.Error(Localization.This_image_contains_a_track_that_is_set_to_start_outside_the_file); - AaruLogging.Error(Localization - .Breaking_track_processing_and_trying_recovery_of_information); + AaruLogging.Error(Localization.Breaking_track_processing_and_trying_recovery_of_information); break; } @@ -1084,9 +993,7 @@ public sealed partial class Nero AaruLogging.Debug(MODULE_NAME, "\tcurrentSession = {0}", currentSession); AaruLogging.Debug(MODULE_NAME, "\tcurrentSessionMaxTrack = {0}", currentSessionMaxTrack); - AaruLogging.Debug(MODULE_NAME, - "\tcurrentSessionCurrentTrack = {0}", - currentSessionCurrentTrack); + AaruLogging.Debug(MODULE_NAME, "\tcurrentSessionCurrentTrack = {0}", currentSessionCurrentTrack); var track = new Track(); @@ -1663,8 +1570,10 @@ public sealed partial class Nero return ErrorNumber.NoError; } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + AaruLogging.Exception(ex, Localization.Exception_occurred_opening_file); AaruLogging.Debug(MODULE_NAME, Localization.Exception_occurred_opening_file); return ErrorNumber.UnexpectedException; diff --git a/Aaru.Images/VHDX/Read.cs b/Aaru.Images/VHDX/Read.cs index b3740f2e1..3066f9d05 100644 --- a/Aaru.Images/VHDX/Read.cs +++ b/Aaru.Images/VHDX/Read.cs @@ -39,6 +39,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Aaru.Logging; +using Sentry; namespace Aaru.Images; @@ -117,8 +118,8 @@ public sealed partial class Vhdx else if((_vRegs[i].flags & REGION_FLAGS_REQUIRED) == REGION_FLAGS_REQUIRED) { AaruLogging.Error(string.Format(Localization - .Found_unsupported_and_required_region_Guid_0_not_proceeding_with_image, - _vRegs[i].guid)); + .Found_unsupported_and_required_region_Guid_0_not_proceeding_with_image, + _vRegs[i].guid)); return ErrorNumber.InvalidArgument; } @@ -168,8 +169,8 @@ public sealed partial class Vhdx else if((_vMets[i].flags & METADATA_FLAGS_REQUIRED) == METADATA_FLAGS_REQUIRED) { AaruLogging.Error(string.Format(Localization - .Found_unsupported_and_required_metadata_Guid_0_not_proceeding_with_image, - _vMets[i].itemId)); + .Found_unsupported_and_required_metadata_Guid_0_not_proceeding_with_image, + _vMets[i].itemId)); return ErrorNumber.InvalidArgument; } @@ -256,8 +257,8 @@ public sealed partial class Vhdx if(_vParHdr.locatorType != _parentTypeVhdxGuid) { AaruLogging.Error(string.Format(Localization - .Found_unsupported_and_required_parent_locator_type_0_not_proceeding_with_image, - _vParHdr.locatorType)); + .Found_unsupported_and_required_parent_locator_type_0_not_proceeding_with_image, + _vParHdr.locatorType)); return ErrorNumber.NotSupported; } @@ -312,8 +313,9 @@ public sealed partial class Vhdx break; } } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); parentWorks = false; } @@ -330,9 +332,10 @@ public sealed partial class Vhdx break; } - catch + catch(Exception ex) { // ignored + SentrySdk.CaptureException(ex); } } else if(string.Compare(entryType, VOLUME_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0 || @@ -354,9 +357,10 @@ public sealed partial class Vhdx break; } - catch + catch(Exception ex) { // ignored + SentrySdk.CaptureException(ex); } } } @@ -443,8 +447,8 @@ public sealed partial class Vhdx if((pt & BAT_FLAGS_MASK) != 0) { AaruLogging.Error(string.Format(Localization - .Unsupported_sector_bitmap_block_flags_0_found_not_proceeding, - pt & BAT_FLAGS_MASK)); + .Unsupported_sector_bitmap_block_flags_0_found_not_proceeding, + pt & BAT_FLAGS_MASK)); return ErrorNumber.InvalidArgument; } diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index b3ea74223..a1f88eb80 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -48,6 +48,7 @@ using Aaru.Decoders.SCSI; using Aaru.Helpers; using Aaru.Logging; using Schemas; +using Sentry; using DMI = Aaru.Decoders.Xbox.DMI; using File = System.IO.File; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; @@ -422,7 +423,10 @@ public sealed partial class ZZZRawImage filter.GetDataForkStream().EnsureRead(data, 0, data.Length); _mediaTags.Add(sidecar.tag, data); } - catch(IOException) {} + catch(IOException ex) + { + SentrySdk.CaptureException(ex); + } } // If there are INQUIRY and IDENTIFY tags, it's ATAPI @@ -1202,9 +1206,10 @@ public sealed partial class ZZZRawImage sr.Close(); } } - catch + catch(Exception ex) { // Do nothing. + SentrySdk.CaptureException(ex); } _imageInfo.ReadableMediaTags = [.._mediaTags.Keys]; diff --git a/Aaru.Partitions/Aaru.Partitions.csproj b/Aaru.Partitions/Aaru.Partitions.csproj index faf1f6073..1742dae7f 100644 --- a/Aaru.Partitions/Aaru.Partitions.csproj +++ b/Aaru.Partitions/Aaru.Partitions.csproj @@ -54,4 +54,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Partitions/GPT.cs b/Aaru.Partitions/GPT.cs index 4c2fec3a2..8677db2da 100644 --- a/Aaru.Partitions/GPT.cs +++ b/Aaru.Partitions/GPT.cs @@ -39,6 +39,7 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Logging; +using Sentry; using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Partitions; @@ -111,8 +112,10 @@ public sealed class GuidPartitionTable : IPartition { hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrBytes); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + return false; } @@ -169,12 +172,10 @@ public sealed class GuidPartitionTable : IPartition Array.Copy(entriesBytes, hdr.entriesSize * i, entryBytes, 0, hdr.entriesSize); entries.Add(Marshal.ByteArrayToStructureLittleEndian(entryBytes)); } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } if(entries.Count == 0) return false; diff --git a/Aaru.Settings/Aaru.Settings.csproj b/Aaru.Settings/Aaru.Settings.csproj index ddfeb9da7..c942b9f3c 100644 --- a/Aaru.Settings/Aaru.Settings.csproj +++ b/Aaru.Settings/Aaru.Settings.csproj @@ -42,4 +42,9 @@ + + + ..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll + + \ No newline at end of file diff --git a/Aaru.Settings/Settings.cs b/Aaru.Settings/Settings.cs index 0e321039f..ced162ca9 100644 --- a/Aaru.Settings/Settings.cs +++ b/Aaru.Settings/Settings.cs @@ -40,6 +40,7 @@ using System.Xml.Serialization; using Aaru.CommonTypes.Interop; using Claunia.PropertyList; using Microsoft.Win32; +using Sentry; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; namespace Aaru.Settings; @@ -129,7 +130,7 @@ public static class Settings PlatformID ptId = DetectOS.GetRealPlatformID(); string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); LocalDbPath = "local.db"; - var oldMainDbPath = "master.db"; + string oldMainDbPath = "master.db"; MainDbPath = "main.db"; try @@ -244,8 +245,10 @@ public static class Settings if(File.Exists(oldMainDbPath)) File.Move(oldMainDbPath, MainDbPath); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + ReportsPath = null; } @@ -497,8 +500,10 @@ public static class Settings break; } } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); + prefsFs?.Close(); prefsSr?.Close(); SetDefaultSettings(); @@ -662,12 +667,10 @@ public static class Settings break; } } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } /// Sets default settings as all statistics, share everything diff --git a/Aaru/Aaru.csproj b/Aaru/Aaru.csproj index 169c976f7..08892b990 100644 --- a/Aaru/Aaru.csproj +++ b/Aaru/Aaru.csproj @@ -77,6 +77,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Aaru/Commands/Archive/Extract.cs b/Aaru/Commands/Archive/Extract.cs index 23b4ad1a0..de5fab8aa 100644 --- a/Aaru/Commands/Archive/Extract.cs +++ b/Aaru/Commands/Archive/Extract.cs @@ -44,6 +44,7 @@ using Aaru.Core; using Aaru.Helpers; using Aaru.Localization; using Aaru.Logging; +using Sentry; using Spectre.Console; using Spectre.Console.Cli; @@ -266,34 +267,34 @@ sealed class ArchiveExtractCommand : Command }); var fi = new FileInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body + try { if(stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + AaruLogging.WriteLine(UI.Written_0_bytes_of_file_1_to_2, uncompressedSize, Markup.Escape(fileName), @@ -326,10 +327,10 @@ sealed class ArchiveExtractCommand : Command if(errno != ErrorNumber.NoError) { AaruLogging.Debug(MODULE_NAME, - UI.Error_0_reading_extended_attribute_1_for_archive_entry_2, - errno, - xattrName, - i); + UI.Error_0_reading_extended_attribute_1_for_archive_entry_2, + errno, + xattrName, + i); continue; } @@ -365,34 +366,34 @@ sealed class ArchiveExtractCommand : Command outputFile.Close(); var fi = new FileInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body + try { if(stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + AaruLogging.WriteLine(UI.Written_0_bytes_of_file_1_to_2, uncompressedSize, Markup.Escape(fileName), diff --git a/Aaru/Commands/Filesystem/ExtractFiles.cs b/Aaru/Commands/Filesystem/ExtractFiles.cs index 7b878e50e..e56b5eec9 100644 --- a/Aaru/Commands/Filesystem/ExtractFiles.cs +++ b/Aaru/Commands/Filesystem/ExtractFiles.cs @@ -44,6 +44,7 @@ using Aaru.Core; using Aaru.Localization; using Aaru.Logging; using JetBrains.Annotations; +using Sentry; using Spectre.Console; using Spectre.Console.Cli; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; @@ -179,15 +180,11 @@ sealed class ExtractFilesCommand : Command AaruLogging.Debug(MODULE_NAME, UI.Correctly_opened_image_file); - AaruLogging.Debug(MODULE_NAME, - UI.Image_without_headers_is_0_bytes, - imageFormat.Info.ImageSize); + AaruLogging.Debug(MODULE_NAME, UI.Image_without_headers_is_0_bytes, imageFormat.Info.ImageSize); AaruLogging.Debug(MODULE_NAME, UI.Image_has_0_sectors, imageFormat.Info.Sectors); - AaruLogging.Debug(MODULE_NAME, - UI.Image_identifies_media_type_as_0, - imageFormat.Info.MediaType); + AaruLogging.Debug(MODULE_NAME, UI.Image_identifies_media_type_as_0, imageFormat.Info.MediaType); Statistics.AddMediaFormat(imageFormat.Format); Statistics.AddMedia(imageFormat.Info.MediaType, false); @@ -385,34 +382,32 @@ sealed class ExtractFilesCommand : Command var di = new DirectoryInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { if(stat.CreationTimeUtc.HasValue) di.CreationTimeUtc = stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.LastWriteTimeUtc.HasValue) di.LastWriteTimeUtc = stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.AccessTimeUtc.HasValue) di.LastAccessTimeUtc = stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body continue; } @@ -491,14 +486,14 @@ sealed class ExtractFilesCommand : Command }); var fi = new FileInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body + try { if(stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try @@ -506,20 +501,20 @@ sealed class ExtractFilesCommand : Command if(stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + AaruLogging.WriteLine(UI.Written_0_bytes_of_xattr_1_from_file_2_to_3, xattrBuf.Length, xattr, @@ -618,34 +613,34 @@ sealed class ExtractFilesCommand : Command outputFile.Close(); var fi = new FileInfo(outputPath); -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body + try { if(stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = stat.CreationTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = stat.LastWriteTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } try { if(stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = stat.AccessTimeUtc.Value; } - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + AaruLogging.WriteLine(UI.Written_0_bytes_of_file_1_to_2, position, Markup.Escape(entry), diff --git a/Aaru/Commands/Image/Compare.cs b/Aaru/Commands/Image/Compare.cs index 3ef5f31a0..d17ee9871 100644 --- a/Aaru/Commands/Image/Compare.cs +++ b/Aaru/Commands/Image/Compare.cs @@ -43,6 +43,7 @@ using Aaru.Core; using Aaru.Helpers; using Aaru.Localization; using Aaru.Logging; +using Sentry; using Spectre.Console; using Spectre.Console.Cli; using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo; @@ -116,9 +117,7 @@ sealed class CompareCommand : Command } if(settings.Verbose) - { AaruLogging.Verbose(UI.First_input_file_format_identified_by_0_1, input1Format.Name, input1Format.Id); - } else AaruLogging.WriteLine(UI.First_input_file_format_identified_by_0, input1Format.Name); @@ -130,9 +129,7 @@ sealed class CompareCommand : Command } if(settings.Verbose) - { AaruLogging.Verbose(UI.Second_input_file_format_identified_by_0_1, input2Format.Name, input2Format.Id); - } else AaruLogging.WriteLine(UI.Second_input_file_format_identified_by_0, input2Format.Name); @@ -473,12 +470,10 @@ sealed class CompareCommand : Command AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical", sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();*/ } -#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch + catch(Exception ex) { - // ignored + SentrySdk.CaptureException(ex); } -#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } }); } diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs index a7bab6cf4..e04d55053 100644 --- a/Aaru/Commands/Media/Dump.cs +++ b/Aaru/Commands/Media/Dump.cs @@ -54,6 +54,7 @@ using Aaru.Core.Logging; using Aaru.Localization; using Aaru.Logging; using Schemas; +using Sentry; using Spectre.Console; using Spectre.Console.Cli; using Dump = Aaru.Core.Devices.Dumping.Dump; @@ -344,8 +345,9 @@ sealed class DumpMediaCommand : Command sr.Close(); } } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); AaruLogging.Error(UI.Incorrect_resume_file_not_continuing); if(isResponse) continue; @@ -384,8 +386,9 @@ sealed class DumpMediaCommand : Command fs.Close(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); AaruLogging.Error(UI.Incorrect_metadata_sidecar_file_not_continuing); if(isResponse) continue; @@ -422,8 +425,9 @@ sealed class DumpMediaCommand : Command sr.Close(); } - catch + catch(Exception ex) { + SentrySdk.CaptureException(ex); AaruLogging.Error(UI.Incorrect_metadata_sidecar_file_not_continuing); if(isResponse) continue; diff --git a/Aaru/Commands/Remote.cs b/Aaru/Commands/Remote.cs index f9bb6e7ba..0937ad8b4 100644 --- a/Aaru/Commands/Remote.cs +++ b/Aaru/Commands/Remote.cs @@ -37,6 +37,7 @@ using System.ComponentModel; using Aaru.CommonTypes.Enums; using Aaru.Core; using Aaru.Logging; +using Sentry; using Spectre.Console; using Spectre.Console.Cli; using Remote = Aaru.Devices.Remote.Remote; @@ -87,8 +88,9 @@ sealed class RemoteCommand : Command AnsiConsole.Write(table); remote.Disconnect(); } - catch(Exception) + catch(Exception ex) { + SentrySdk.CaptureException(ex); AaruLogging.Error("Error connecting to host."); return (int)ErrorNumber.CannotOpenDevice; diff --git a/Aaru/LoggingInterceptor.cs b/Aaru/LoggingInterceptor.cs index 4cded98e0..53cd68578 100644 --- a/Aaru/LoggingInterceptor.cs +++ b/Aaru/LoggingInterceptor.cs @@ -35,12 +35,25 @@ public class LoggingInterceptor : ICommandInterceptor .Enrich.FromLogContext() .WriteTo.Logger(lc => lc.Filter .ByIncludingOnly(e => - e.Level is LogEventLevel - .Debug + e.Level is LogEventLevel.Debug or LogEventLevel.Verbose or LogEventLevel.Error) - .WriteTo - .Spectre(renderTextAsMarkup: true)); + .WriteTo.Spectre(renderTextAsMarkup: true) + .WriteTo.Sentry(o => + { + o.Dsn = + "https://153a04fb97b78bb57a8013b8b30db04f@sentry.claunia.com/8"; + + // What to record as Sentry Breadcrumbs + o.MinimumBreadcrumbLevel = + LogEventLevel.Debug; + + // What to send to Sentry as Events + o.MinimumEventLevel = LogEventLevel.Error; + + // If you already call SentrySdk.Init elsewhere: + // o.InitializeSdk = false; + })); // If logfile is present, add file sink and redirect Spectre.Console output if(!string.IsNullOrWhiteSpace(global.LogFile)) diff --git a/Aaru/Main.cs b/Aaru/Main.cs index a6e715276..b7b84e386 100644 --- a/Aaru/Main.cs +++ b/Aaru/Main.cs @@ -52,6 +52,7 @@ using Aaru.Logging; using Aaru.Settings; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; +using Sentry; using Serilog; using Spectre.Console; using Spectre.Console.Cli; @@ -68,11 +69,6 @@ class MainClass public static async Task Main([NotNull] string[] args) { - IAnsiConsole stderrConsole = AnsiConsole.Create(new AnsiConsoleSettings - { - Out = new AnsiConsoleOutput(Console.Error) - }); - object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); @@ -86,334 +82,374 @@ class MainClass if(args.Length == 1 && args[0].Equals("gui", StringComparison.InvariantCultureIgnoreCase)) return Gui.Main.Start(args); - AaruLogging.WriteLineEvent += (format, objects) => + SentrySdk.Init(options => { - if(objects is null) - AnsiConsole.MarkupLine(format); - else - AnsiConsole.MarkupLine(format, objects); + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = "https://153a04fb97b78bb57a8013b8b30db04f@sentry.claunia.com/8"; - // Format the string so we can remove the markup - if(format is null) return; + // When debug is enabled, the Sentry client will emit detailed debugging information to the console. + // This might be helpful, or might interfere with the normal operation of your application. + // We enable it here for demonstration purposes when first trying Sentry. + // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. + //options.Debug = true; - string formatted = objects is null ? format : string.Format(format, objects); - formatted = Markup.Remove(formatted); - Log.Information(formatted); - }; + // This option is recommended. It enables Sentry's "Release Health" feature. + options.AutoSessionTracking = true; - AaruLogging.WriteEvent += (format, objects) => - { - if(objects is null) - AnsiConsole.Markup(format); - else - AnsiConsole.Markup(format, objects); + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production. + options.TracesSampleRate = 1.0; - // Format the string so we can remove the markup - if(format is null) return; - - string formatted = objects is null ? format : string.Format(format, objects); - formatted = Markup.Remove(formatted); - Log.Information(formatted); - }; - - AaruLogging.ErrorEvent += Log.Error; - AaruLogging.VerboseEvent += Log.Verbose; - AaruLogging.DebugEvent += (module, format, objects) => Log.Debug($"[blue]{module}[/] {format}", objects); - AaruLogging.WriteExceptionEvent += Log.Error; - AaruLogging.InformationEvent += Log.Information; - - Settings.Settings.LoadSettings(); - - AaruContext ctx = null; + options.IsGlobalModeEnabled = true; + }); try { - ctx = AaruContext.Create(Settings.Settings.LocalDbPath, false); - await ctx.Database.MigrateAsync(); - } - catch(NotSupportedException) - { + AaruLogging.WriteLineEvent += (format, objects) => + { + if(objects is null) + AnsiConsole.MarkupLine(format); + else + AnsiConsole.MarkupLine(format, objects); + + // Format the string so we can remove the markup + if(format is null) return; + + string formatted = objects is null ? format : string.Format(format, objects); + formatted = Markup.Remove(formatted); + Log.Information(formatted); + }; + + AaruLogging.WriteEvent += (format, objects) => + { + if(objects is null) + AnsiConsole.Markup(format); + else + AnsiConsole.Markup(format, objects); + + // Format the string so we can remove the markup + if(format is null) return; + + string formatted = objects is null ? format : string.Format(format, objects); + formatted = Markup.Remove(formatted); + Log.Information(formatted); + }; + + AaruLogging.ErrorEvent += Log.Error; + AaruLogging.VerboseEvent += Log.Verbose; + AaruLogging.DebugEvent += (module, format, objects) => Log.Debug($"[blue]{module}[/] {format}", objects); + AaruLogging.WriteExceptionEvent += Log.Error; + AaruLogging.InformationEvent += Log.Information; + + Settings.Settings.LoadSettings(); + + AaruContext ctx = null; + try { - if(ctx is not null) + ctx = AaruContext.Create(Settings.Settings.LocalDbPath, false); + await ctx.Database.MigrateAsync(); + } + catch(NotSupportedException) + { + try { - await ctx.Database.CloseConnectionAsync(); - await ctx.DisposeAsync(); + if(ctx is not null) + { + await ctx.Database.CloseConnectionAsync(); + await ctx.DisposeAsync(); + } + } + catch(Exception ex) + { + // Should not ever arrive here, but if it does, keep trying to replace it anyway + SentrySdk.CaptureException(ex); } - } - catch(Exception) - { - // Should not ever arrive here, but if it does, keep trying to replace it anyway - } - File.Delete(Settings.Settings.LocalDbPath); - ctx = AaruContext.Create(Settings.Settings.LocalDbPath); - await ctx.Database.EnsureCreatedAsync(); + File.Delete(Settings.Settings.LocalDbPath); + ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + await ctx.Database.EnsureCreatedAsync(); - await ctx.Database - .ExecuteSqlRawAsync("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); - - foreach(string migration in await ctx.Database.GetPendingMigrationsAsync()) - { -#pragma warning disable EF1002 await ctx.Database - .ExecuteSqlRawAsync($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ - migration}', '0.0.0')"); + .ExecuteSqlRawAsync("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); + + foreach(string migration in await ctx.Database.GetPendingMigrationsAsync()) + { +#pragma warning disable EF1002 + await ctx.Database + .ExecuteSqlRawAsync($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ + migration}', '0.0.0')"); #pragma warning restore EF1002 + } + + await ctx.SaveChangesAsync(); } + // Remove duplicates + foreach(var duplicate in ctx.SeenDevices.AsEnumerable() + .GroupBy(a => new + { + a.Manufacturer, + a.Model, + a.Revision, + a.Bus + }) + .Where(a => a.Count() > 1) + .Distinct() + .Select(a => a.Key)) + { + ctx.RemoveRange(ctx.SeenDevices + .Where(d => d.Manufacturer == duplicate.Manufacturer && + d.Model == duplicate.Model && + d.Revision == duplicate.Revision && + d.Bus == duplicate.Bus) + .Skip(1)); + } + + // Remove nulls + ctx.RemoveRange(ctx.SeenDevices.Where(d => d.Manufacturer == null && + d.Model == null && + d.Revision == null)); + await ctx.SaveChangesAsync(); - } - // Remove duplicates - foreach(var duplicate in ctx.SeenDevices.AsEnumerable() - .GroupBy(a => new - { - a.Manufacturer, - a.Model, - a.Revision, - a.Bus - }) - .Where(a => a.Count() > 1) - .Distinct() - .Select(a => a.Key)) - { - ctx.RemoveRange(ctx.SeenDevices - .Where(d => d.Manufacturer == duplicate.Manufacturer && - d.Model == duplicate.Model && - d.Revision == duplicate.Revision && - d.Bus == duplicate.Bus) - .Skip(1)); - } + bool mainDbUpdate = false; - // Remove nulls - ctx.RemoveRange(ctx.SeenDevices.Where(d => d.Manufacturer == null && d.Model == null && d.Revision == null)); - - await ctx.SaveChangesAsync(); - - bool mainDbUpdate = false; - - if(!File.Exists(Settings.Settings.MainDbPath)) - { - mainDbUpdate = true; - await UpdateCommand.DoUpdateAsync(true); - } - - var mainContext = AaruContext.Create(Settings.Settings.MainDbPath, false); - - if((await mainContext.Database.GetPendingMigrationsAsync()).Any()) - { - AaruLogging.WriteLine(UI.New_database_version_updating); - - try + if(!File.Exists(Settings.Settings.MainDbPath)) { - File.Delete(Settings.Settings.MainDbPath); - } - catch(Exception) - { - AaruLogging.Error(UI.Exception_trying_to_remove_old_database_version); - AaruLogging.Error(UI.Please_manually_remove_file_at_0, Settings.Settings.MainDbPath); - - return (int)ErrorNumber.CannotRemoveDatabase; + mainDbUpdate = true; + await UpdateCommand.DoUpdateAsync(true); } - await mainContext.Database.CloseConnectionAsync(); - await mainContext.DisposeAsync(); - await UpdateCommand.DoUpdateAsync(true); - } + var mainContext = AaruContext.Create(Settings.Settings.MainDbPath, false); - // GDPR level compliance does not match and there are no arguments or the arguments are neither GUI neither configure. - if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL && - (args.Length < 1 || - args.Length >= 1 && - !args[0].Equals("gui", StringComparison.InvariantCultureIgnoreCase) && - !args[0].Equals("configure", StringComparison.InvariantCultureIgnoreCase))) - new ConfigureCommand().DoConfigure(true); + if((await mainContext.Database.GetPendingMigrationsAsync()).Any()) + { + AaruLogging.WriteLine(UI.New_database_version_updating); - Statistics.LoadStats(); + try + { + File.Delete(Settings.Settings.MainDbPath); + } + catch(Exception ex) + { + SentrySdk.CaptureException(ex); + AaruLogging.Error(UI.Exception_trying_to_remove_old_database_version); + AaruLogging.Error(UI.Please_manually_remove_file_at_0, Settings.Settings.MainDbPath); - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + return (int)ErrorNumber.CannotRemoveDatabase; + } - // There are too many places that depend on this being inited to be sure all are covered, so init it here. - PluginBase.Init(); + await mainContext.Database.CloseConnectionAsync(); + await mainContext.DisposeAsync(); + await UpdateCommand.DoUpdateAsync(true); + } - var app = new CommandApp(); + // GDPR level compliance does not match and there are no arguments or the arguments are neither GUI neither configure. + if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL && + (args.Length < 1 || + args.Length >= 1 && + !args[0].Equals("gui", StringComparison.InvariantCultureIgnoreCase) && + !args[0].Equals("configure", StringComparison.InvariantCultureIgnoreCase))) + new ConfigureCommand().DoConfigure(true); - app.Configure(config => - { - config.UseAssemblyInformationalVersion(); + Statistics.LoadStats(); - config.AddBranch("archive", - archive => - { - archive.SetDescription(UI.Archive_Command_Family_Description); + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - archive.AddCommand("list") - .WithAlias("l") - .WithAlias("ls") - .WithDescription(UI.Archive_List_Command_Description); + // There are too many places that depend on this being inited to be sure all are covered, so init it here. + PluginBase.Init(); - archive.AddCommand("extract") - .WithAlias("x") - .WithDescription(UI.Archive_Extract_Command_Description); + var app = new CommandApp(); - archive.AddCommand("info") - .WithAlias("i") - .WithDescription(UI.Archive_Info_Command_Description); - }) - .WithAlias("arc"); + app.Configure(config => + { + config.UseAssemblyInformationalVersion(); - config.AddBranch("device", - device => - { - device.SetDescription(UI.Device_Command_Family_Description); + config.AddBranch("archive", + archive => + { + archive.SetDescription(UI.Archive_Command_Family_Description); - device.AddCommand("report") - .WithDescription(UI.Device_Report_Command_Description); + archive.AddCommand("list") + .WithAlias("l") + .WithAlias("ls") + .WithDescription(UI.Archive_List_Command_Description); - device.AddCommand("info") - .WithAlias("i") - .WithDescription(UI.Device_Info_Command_Description); + archive.AddCommand("extract") + .WithAlias("x") + .WithDescription(UI.Archive_Extract_Command_Description); - device.AddCommand("list") - .WithAlias("l") - .WithAlias("ls") - .WithDescription(UI.Device_List_Command_Description); - }) - .WithAlias("dev"); + archive.AddCommand("info") + .WithAlias("i") + .WithDescription(UI.Archive_Info_Command_Description); + }) + .WithAlias("arc"); - config.AddBranch("filesystem", - fs => + config.AddBranch("device", + device => { - fs.SetDescription(UI.Filesystem_Command_Family_Description); + device.SetDescription(UI.Device_Command_Family_Description); - fs.AddCommand("extract") - .WithAlias("x") - .WithDescription(UI.Filesystem_Extract_Command_Description); + device.AddCommand("report") + .WithDescription(UI.Device_Report_Command_Description); - fs.AddCommand("info") - .WithAlias("i") - .WithDescription(UI.Filesystem_Info_Command_Description); + device.AddCommand("info") + .WithAlias("i") + .WithDescription(UI.Device_Info_Command_Description); - fs.AddCommand("list") - .WithAlias("ls") - .WithDescription(UI.Filesystem_List_Command_Description); - - fs.AddCommand("options") - .WithDescription(UI.Filesystem_Options_Command_Description); + device.AddCommand("list") + .WithAlias("l") + .WithAlias("ls") + .WithDescription(UI.Device_List_Command_Description); }) - .WithAlias("fs") - .WithAlias("fi"); + .WithAlias("dev"); - config.AddBranch("image", - image => - { - image.SetDescription(UI.Image_Command_Family_Description); + config.AddBranch("filesystem", + fs => + { + fs.SetDescription(UI.Filesystem_Command_Family_Description); - image.AddCommand("checksum") - .WithAlias("chk") - .WithDescription(UI.Image_Checksum_Command_Description); + fs.AddCommand("extract") + .WithAlias("x") + .WithDescription(UI.Filesystem_Extract_Command_Description); - image.AddCommand("compare") - .WithAlias("cmp") - .WithDescription(UI.Image_Compare_Command_Description); + fs.AddCommand("info") + .WithAlias("i") + .WithDescription(UI.Filesystem_Info_Command_Description); - image.AddCommand("convert") - .WithAlias("cvt") - .WithDescription(UI.Image_Convert_Command_Description); + fs.AddCommand("list") + .WithAlias("ls") + .WithDescription(UI.Filesystem_List_Command_Description); - image.AddCommand("create-sidecar") - .WithAlias("cs") - .WithDescription(UI.Image_Create_Sidecar_Command_Description); + fs.AddCommand("options") + .WithDescription(UI.Filesystem_Options_Command_Description); + }) + .WithAlias("fs") + .WithAlias("fi"); - image.AddCommand("decode") - .WithDescription(UI.Image_Decode_Command_Description); + config.AddBranch("image", + image => + { + image.SetDescription(UI.Image_Command_Family_Description); - image.AddCommand("entropy") - .WithDescription(UI.Image_Entropy_Command_Description); + image.AddCommand("checksum") + .WithAlias("chk") + .WithDescription(UI.Image_Checksum_Command_Description); - image.AddCommand("info") - .WithAlias("i") - .WithDescription(UI.Image_Info_Command_Description); + image.AddCommand("compare") + .WithAlias("cmp") + .WithDescription(UI.Image_Compare_Command_Description); - image.AddCommand("options") - .WithDescription(UI.Image_Options_Command_Description); + image.AddCommand("convert") + .WithAlias("cvt") + .WithDescription(UI.Image_Convert_Command_Description); - image.AddCommand("print-hex") - .WithAlias("ph") - .WithDescription(UI.Image_Print_Command_Description); + image.AddCommand("create-sidecar") + .WithAlias("cs") + .WithDescription(UI.Image_Create_Sidecar_Command_Description); - image.AddCommand("verify") - .WithAlias("v") - .WithDescription(UI.Image_Verify_Command_Description); - }) - .WithAlias("i") - .WithAlias("img"); + image.AddCommand("decode") + .WithDescription(UI.Image_Decode_Command_Description); - config.AddBranch("media", - media => - { - media.SetDescription(UI.Media_Command_Family_Description); + image.AddCommand("entropy") + .WithDescription(UI.Image_Entropy_Command_Description); - media.AddCommand("info") - .WithAlias("i") - .WithDescription(UI.Media_Info_Command_Description); + image.AddCommand("info") + .WithAlias("i") + .WithDescription(UI.Image_Info_Command_Description); - media.AddCommand("scan") - .WithAlias("s") - .WithDescription(UI.Media_Scan_Command_Description); + image.AddCommand("options") + .WithDescription(UI.Image_Options_Command_Description); - media.AddCommand("dump") - .WithAlias("d") - .WithDescription(UI.Media_Dump_Command_Description); - }) - .WithAlias("m"); + image.AddCommand("print-hex") + .WithAlias("ph") + .WithDescription(UI.Image_Print_Command_Description); - config.AddBranch("database", - db => - { - db.SetDescription(UI.Database_Command_Family_Description); + image.AddCommand("verify") + .WithAlias("v") + .WithDescription(UI.Image_Verify_Command_Description); + }) + .WithAlias("i") + .WithAlias("img"); - db.AddCommand("stats") - .WithDescription(UI.Database_Stats_Command_Description); + config.AddBranch("media", + media => + { + media.SetDescription(UI.Media_Command_Family_Description); - db.AddCommand("update") - .WithDescription(UI.Database_Update_Command_Description); - }) - .WithAlias("db"); + media.AddCommand("info") + .WithAlias("i") + .WithDescription(UI.Media_Info_Command_Description); - config.AddCommand("configure") - .WithAlias("cfg") - .WithDescription(UI.Configure_Command_Description); + media.AddCommand("scan") + .WithAlias("s") + .WithDescription(UI.Media_Scan_Command_Description); - config.AddCommand("formats") - .WithAlias("fmt") - .WithDescription(UI.List_Formats_Command_Description); + media.AddCommand("dump") + .WithAlias("d") + .WithDescription(UI.Media_Dump_Command_Description); + }) + .WithAlias("m"); - config.AddCommand("list-encodings") - .WithAlias("le") - .WithDescription(UI.List_Encodings_Command_Description); + config.AddBranch("database", + db => + { + db.SetDescription(UI.Database_Command_Family_Description); - config.AddCommand("list-namespaces") - .WithAlias("ln") - .WithDescription(UI.List_Namespaces_Command_Description); + db.AddCommand("stats") + .WithDescription(UI.Database_Stats_Command_Description); - config.AddCommand("remote").WithAlias("rem").WithDescription(UI.Remote_Command_Description); + db.AddCommand("update") + .WithDescription(UI.Database_Update_Command_Description); + }) + .WithAlias("db"); - config.SetInterceptor(new LoggingInterceptor()); - config.SetInterceptor(new PausingInterceptor()); - }); + config.AddCommand("configure") + .WithAlias("cfg") + .WithDescription(UI.Configure_Command_Description); - int ret = await app.RunAsync(args); + config.AddCommand("formats") + .WithAlias("fmt") + .WithDescription(UI.List_Formats_Command_Description); - await Statistics.SaveStatsAsync(); + config.AddCommand("list-encodings") + .WithAlias("le") + .WithDescription(UI.List_Encodings_Command_Description); - if(!PauseBeforeExiting) return ret; + config.AddCommand("list-namespaces") + .WithAlias("ln") + .WithDescription(UI.List_Namespaces_Command_Description); - AaruLogging.WriteLine(UI.Press_any_key_to_exit); - Console.ReadKey(); + config.AddCommand("remote") + .WithAlias("rem") + .WithDescription(UI.Remote_Command_Description); - return ret; + config.SetInterceptor(new LoggingInterceptor()); + config.SetInterceptor(new PausingInterceptor()); + }); + + int ret = await app.RunAsync(args); + + await Statistics.SaveStatsAsync(); + + if(!PauseBeforeExiting) return ret; + + AaruLogging.WriteLine(UI.Press_any_key_to_exit); + Console.ReadKey(); + + return ret; + } + catch(Exception ex) + { + SentrySdk.CaptureException(ex); + AnsiConsole.WriteException(ex); + + return (int)ErrorNumber.UnexpectedException; + } } internal static void PrintCopyright() diff --git a/Directory.Packages.props b/Directory.Packages.props index d83840f7f..7c1f7a204 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -40,6 +40,8 @@ + +