1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-14 23:33:34 +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,14 +18,26 @@
if (Handler?.MauiContext == null) { return; } if (Handler?.MauiContext == null) { return; }
if (_iconImage?.Source == null) { return; } if (_iconImage?.Source == null) { return; }
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext); try
if (result == null) {
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext);
if (result == null)
{
Icon_Error(sender, e);
}
else
{
Icon_Success(sender, e);
}
}
catch (InvalidOperationException) //Can occur with incorrect/malformed uris
{ {
Icon_Error(sender, e); Icon_Error(sender, e);
} }
else catch(Exception ex)
{ {
Icon_Success(sender, e); 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,14 +47,26 @@ namespace Bit.App.Controls
if (Handler?.MauiContext == null) { return; } if (Handler?.MauiContext == null) { return; }
if (_iconImage?.Source == null) { return; } if (_iconImage?.Source == null) { return; }
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext); try
if (result == null) {
var result = await _iconImage.Source.GetPlatformImageAsync(Handler.MauiContext);
if (result == null)
{
Icon_Error(sender, e);
}
else
{
Icon_Success(sender, e);
}
}
catch (InvalidOperationException) //Can occur with incorrect/malformed uris
{ {
Icon_Error(sender, e); Icon_Error(sender, e);
} }
else catch(Exception ex)
{ {
Icon_Success(sender, e); LoggerHelper.LogEvenIfCantBeResolved(ex);
Icon_Error(sender, e);
} }
} }
} }