[EC-324] Added more logging for information on list crash (#1993)

* EC-324 Added more logging for trying to get more information on list out of range crash on AppCenter

* EC-324 Fix include on iOS.Core.csproj on iOS CollectionView files
This commit is contained in:
Federico Maccaroni 2022-07-14 18:54:45 -03:00 committed by GitHub
parent 8f3a4b98a5
commit 1f2fb3f796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 1 deletions

View file

@ -0,0 +1,16 @@
using System;
namespace Bit.iOS.Core.Renderers.CollectionView
{
public class CollectionException : Exception
{
public CollectionException(string message)
: base(message)
{
}
public CollectionException(string message, Exception innerEx)
: base(message, innerEx)
{
}
}
}

View file

@ -1,6 +1,8 @@
using System;
using Bit.App.Controls;
using Bit.Core.Services;
using Foundation;
using UIKit;
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Renderers.CollectionView
@ -13,6 +15,11 @@ namespace Bit.iOS.Core.Renderers.CollectionView
{
}
protected override UICollectionViewDelegateFlowLayout CreateDelegator()
{
return new ExtendedGroupableItemsViewDelegator<TItemsView, ExtendedGroupableItemsViewController<TItemsView>>(ItemsViewLayout, this);
}
protected override void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
{
try
@ -21,7 +28,17 @@ namespace Bit.iOS.Core.Renderers.CollectionView
}
catch (Exception ex) when (ItemsView?.ExtraDataForLogging != null)
{
throw new Exception("Error in ExtendedCollectionView, extra data: " + ItemsView.ExtraDataForLogging, ex);
var colEx = new CollectionException("Error in ExtendedCollectionView -> ExtendedGroupableItemsViewController, extra data: " + ItemsView.ExtraDataForLogging, ex);
try
{
LoggerHelper.LogEvenIfCantBeResolved(colEx);
}
catch
{
// Do nothing in here, this is temporary to get more info about the crash, if the logger fails, we want to get the info
// by crashing with the original exception and not the logger one
}
throw colEx;
}
}
}

View file

@ -0,0 +1,43 @@
using System;
using Bit.App.Controls;
using Bit.Core.Services;
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Renderers.CollectionView
{
public class ExtendedGroupableItemsViewDelegator<TItemsView, TViewController> : GroupableItemsViewDelegator<TItemsView, TViewController>
where TItemsView : ExtendedCollectionView
where TViewController : GroupableItemsViewController<TItemsView>
{
public ExtendedGroupableItemsViewDelegator(ItemsViewLayout itemsViewLayout, TViewController itemsViewController)
: base(itemsViewLayout, itemsViewController)
{
}
public override CGSize GetSizeForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath)
{
// Added this to get extra information on a crash when getting the size for an item.
try
{
return base.GetSizeForItem(collectionView, layout, indexPath);
}
catch (Exception ex) when (ViewController?.ItemsView?.ExtraDataForLogging != null)
{
var colEx = new CollectionException("Error in ExtendedCollectionView -> ExtendedGroupableItemsViewDelegator, extra data: " + ViewController.ItemsView.ExtraDataForLogging, ex);
try
{
LoggerHelper.LogEvenIfCantBeResolved(colEx);
}
catch
{
// Do nothing in here, this is temporary to get more info about the crash, if the logger fails, we want to get the info
// by crashing with the original exception and not the logger one
}
throw colEx;
}
}
}
}

View file

@ -201,6 +201,8 @@
<Compile Include="Renderers\CollectionView\ExtendedCollectionViewRenderer.cs" />
<Compile Include="Renderers\CollectionView\ExtendedGroupableItemsViewController.cs" />
<Compile Include="Utilities\UISearchBarExtensions.cs" />
<Compile Include="Renderers\CollectionView\CollectionException.cs" />
<Compile Include="Renderers\CollectionView\ExtendedGroupableItemsViewDelegator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\App\App.csproj">