private async Task <Exception> HandleStorageRelatedExceptionAsync(Exception e)
        {
            // Check if database is corrupted, we have evidence (https://github.com/microsoft/appcenter-sdk-dotnet/issues/1184)
            // that it's not always originated by a proper SQLiteException (which would then be converted to StorageException in StorageAdapter).
            // If it was always the right type then the exception would not have been unobserved in that application before we changed the re-throw logic here.
            // But the message is definitely "Corrupt" and thus unfortunately that is the only check we seem to be able to do as opposed to type/property checking.
            if (e.Message == "Corrupt" || e.InnerException?.Message == "Corrupt")
            {
                AppCenterLog.Error(AppCenterLog.LogTag, "Database corruption detected, deleting the file and starting fresh...", e);
                await _storageAdapter.DeleteDatabaseFileAsync().ConfigureAwait(false);
                await InitializeDatabaseAsync().ConfigureAwait(false);
            }

            // Return exception to re-throw.
            if (e is StorageException)
            {
                // This is the expected case, storage adapter already wraps exception as StorageException, so return as is.
                return(e);
            }

            // Tasks should already be throwing only storage exceptions, but in case any are missed,
            // which has happened (the Corrupt exception mentioned previously), catch them here and wrap in a storage exception. This will prevent
            // the exception from being unobserved.
            return(new StorageException(e));
        }