1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-28 10:54:59 +02:00
bitwarden-mobile/src/Core/Utilities/TaskExtensions.cs
Federico Maccaroni db7ca3b93e
BEEEP: Abstract and Centralize Logging (#1663)
* Abstracted App Center Logging into its own component, so that we can have it centralized in one place and we avoid checking for FDroid on all the places we want to use it

* Implemented the new logger where Crashes.TrackError was being used except on some specific cases

* Improved logging, added a debug logger and removed AppCenter to be used on DEBUG
2022-03-02 14:15:16 -03:00

29 lines
833 B
C#

using System;
using System.Threading.Tasks;
using Bit.Core.Services;
namespace Bit.Core.Utilities
{
public static class TaskExtensions
{
/// <summary>
/// Fires a task and ignores any exception.
/// See http://stackoverflow.com/a/22864616/344182
/// </summary>
/// <param name="task">The task to be forgotten.</param>
/// <param name="onException">Action to be called on exception.</param>
public static async void FireAndForget(this Task task, Action<Exception> onException = null)
{
try
{
await task.ConfigureAwait(false);
}
catch (Exception ex)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
onException?.Invoke(ex);
}
}
}
}