Add Sentry to catch exceptions.

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

View File

@@ -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<ContainerSuperBlock>(sector);
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
return false;
}
@@ -86,8 +90,10 @@ public sealed partial class APFS
{
nxSb = Marshal.ByteArrayToStructureLittleEndian<ContainerSuperBlock>(sector);
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
return;
}

View File

@@ -68,4 +68,9 @@
<ItemGroup>
<ProjectReference Include="..\Aaru.Generators\Aaru.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
</ItemGroup>
<ItemGroup>
<Reference Include="Sentry">
<HintPath>..\..\..\..\.nuget\packages\sentry\5.14.1\lib\net9.0\Sentry.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -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<SuperBlock>(sector);
}
catch
catch(Exception ex)
{
SentrySdk.CaptureException(ex);
return false;
}

View File

@@ -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;
}
}

View File

@@ -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<DirectoryEntry>(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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}