1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-10 13:23:39 +00:00

Added try catch and logging to Image.OnLoaded methods

This commit is contained in:
Dinis Vieira
2024-03-27 21:45:14 +00:00
parent 583fd6ba1e
commit 6b15bfce12
2 changed files with 36 additions and 9 deletions

View File

@@ -1,4 +1,6 @@
namespace Bit.App.Controls using Bit.Core.Services;
namespace Bit.App.Controls
{ {
public partial class AuthenticatorViewCell : BaseCipherViewCell public partial class AuthenticatorViewCell : BaseCipherViewCell
{ {
@@ -16,6 +18,8 @@
if (Handler?.MauiContext == null) { return; } if (Handler?.MauiContext == null) { return; }
if (_iconImage?.Source == null) { return; } if (_iconImage?.Source == null) { return; }
try
{
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext); var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext);
if (result == null) if (result == null)
{ {
@@ -26,5 +30,15 @@
Icon_Success(sender, e); Icon_Success(sender, e);
} }
} }
catch (InvalidOperationException) //Can occur with incorrect/malformed uris
{
Icon_Error(sender, e);
}
catch(Exception ex)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
Icon_Error(sender, e);
}
}
} }
} }

View File

@@ -1,6 +1,7 @@
using System.Windows.Input; using System.Windows.Input;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Pages; using Bit.App.Pages;
using Bit.Core.Services;
using Bit.Core.Utilities; using Bit.Core.Utilities;
namespace Bit.App.Controls namespace Bit.App.Controls
@@ -46,6 +47,8 @@ namespace Bit.App.Controls
if (Handler?.MauiContext == null) { return; } if (Handler?.MauiContext == null) { return; }
if (_iconImage?.Source == null) { return; } if (_iconImage?.Source == null) { return; }
try
{
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext); var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext);
if (result == null) if (result == null)
{ {
@@ -56,5 +59,15 @@ namespace Bit.App.Controls
Icon_Success(sender, e); Icon_Success(sender, e);
} }
} }
catch (InvalidOperationException) //Can occur with incorrect/malformed uris
{
Icon_Error(sender, e);
}
catch(Exception ex)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
Icon_Error(sender, e);
}
}
} }
} }