Improve error handling
This commit is contained in:
parent
17f7dcdf12
commit
3663bbb241
@ -32,6 +32,8 @@ namespace Pal.Client.DependencyInjection
|
||||
}
|
||||
|
||||
private async Task FetchFloorStatistics()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_configuration.HasRoleOnCurrentServer(RemoteApi.RemoteUrl, "statistics:view"))
|
||||
{
|
||||
@ -39,8 +41,6 @@ namespace Pal.Client.DependencyInjection
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var (success, floorStatistics) = await _remoteApi.FetchStatistics();
|
||||
if (success)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Pal.Client.Database;
|
||||
@ -18,12 +19,20 @@ namespace Pal.Client.Floors.Tasks
|
||||
public void Start()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
ILogger<T> logger = scope.ServiceProvider.GetRequiredService<ILogger<T>>();
|
||||
using var dbContext = scope.ServiceProvider.GetRequiredService<PalClientContext>();
|
||||
|
||||
Run(dbContext, logger);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DependencyInjectionContext.LoggerProvider.CreateLogger<DbTask<T>>()
|
||||
.LogError(e, "Failed to run DbTask");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -142,9 +142,12 @@ namespace Pal.Client
|
||||
Task.Run(async () =>
|
||||
{
|
||||
IServiceScope rootScope;
|
||||
Chat chat;
|
||||
|
||||
try
|
||||
{
|
||||
rootScope = await _rootScopeCompletionSource.Task;
|
||||
chat = rootScope.ServiceProvider.GetRequiredService<Chat>();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -152,17 +155,16 @@ namespace Pal.Client
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IPalacePalConfiguration configuration =
|
||||
rootScope.ServiceProvider.GetRequiredService<IPalacePalConfiguration>();
|
||||
Chat chat = rootScope.ServiceProvider.GetRequiredService<Chat>();
|
||||
if (configuration.FirstUse && arguments != "" && arguments != "config")
|
||||
{
|
||||
chat.Error(Localization.Error_FirstTimeSetupRequired);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sp = rootScope.ServiceProvider;
|
||||
|
||||
switch (arguments)
|
||||
|
@ -472,7 +472,17 @@ namespace Pal.Client.Windows
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
_lastImportCts = cts;
|
||||
|
||||
Task.Run(async () => { _lastImport = await _importService.FindLast(cts.Token); }, cts.Token);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_lastImport = await _importService.FindLast(cts.Token);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Unable to fetch last import");
|
||||
}
|
||||
}, cts.Token);
|
||||
}
|
||||
|
||||
private void DoExport(string destinationPath)
|
||||
|
Loading…
Reference in New Issue
Block a user