Log readable message for sqlite-net-pcl issue

This commit is contained in:
Ivan Matkov 2017-12-08 23:06:27 +03:00
Родитель bac2324751
Коммит af28088fc6
2 изменённых файлов: 39 добавлений и 16 удалений

Просмотреть файл

@ -193,7 +193,22 @@ namespace Microsoft.AppCenter
{
lock (AppCenterLock)
{
Instance.StartInstanceAndConfigure(appSecret, services);
try
{
Instance.InstanceConfigure(appSecret);
}
catch (AppCenterException ex)
{
AppCenterLog.Error(AppCenterLog.LogTag, ConfigurationErrorMessage, ex);
}
try
{
Instance.StartInstance(services);
}
catch (AppCenterException ex)
{
AppCenterLog.Error(AppCenterLog.LogTag, StartErrorMessage, ex);
}
}
}
@ -400,18 +415,6 @@ namespace Microsoft.AppCenter
AppCenterLog.Info(AppCenterLog.LogTag, $"'{service.GetType().Name}' service started.");
}
public void StartInstanceAndConfigure(string appSecret, params Type[] services)
{
try
{
InstanceConfigure(appSecret);
StartInstance(services);
}
catch (AppCenterException ex)
{
AppCenterLog.Warn(AppCenterLog.LogTag, ex.Message);
}
}
internal Guid InstanceCorrelationId = Guid.Empty;
// We don't support Distribute in UWP.

Просмотреть файл

@ -1,12 +1,13 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SQLite;
using Microsoft.AppCenter.Ingestion.Models;
using Microsoft.AppCenter.Ingestion.Models.Serialization;
using Newtonsoft.Json;
using SQLite;
namespace Microsoft.AppCenter.Storage
{
@ -41,7 +42,7 @@ namespace Microsoft.AppCenter.Storage
/// <summary>
/// Creates an instance of Storage
/// </summary>
public Storage() : this(new StorageAdapter(Database))
public Storage() : this(DefaultAdapter())
{
}
@ -55,6 +56,25 @@ namespace Microsoft.AppCenter.Storage
_queueFlushTask = Task.Run(FlushQueueAsync);
}
private static IStorageAdapter DefaultAdapter()
{
try
{
return new StorageAdapter(Database);
}
catch (FileLoadException e)
{
if (e.Message.Contains("SQLite-net"))
{
AppCenterLog.Error(AppCenterLog.LogTag,
"If you are using sqlite-net-pcl version 1.4.118, please use a different version. " +
"There is a known bug in this version that will prevent App Center from working properly.");
throw new StorageException("Cannot initialize SQLite library.", e);
}
throw;
}
}
/// <summary>
/// Asynchronously adds a log to storage
/// </summary>