зеркало из https://github.com/dotnet/razor.git
Log errors in FileWatcherBasedRazorProjectInfoDriver
This commit is contained in:
Родитель
a61c4e1a50
Коммит
8bf003147b
|
@ -73,11 +73,12 @@ internal partial class FileWatcherBasedRazorProjectInfoDriver : AbstractRazorPro
|
|||
{
|
||||
using var stream = File.OpenRead(filePath);
|
||||
|
||||
var razorProjectInfo = await RazorProjectInfo
|
||||
.DeserializeFromAsync(stream, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
var razorProjectInfo = await TryDeserializeAsync(filePath, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
EnqueueUpdate(razorProjectInfo);
|
||||
if (razorProjectInfo is not null)
|
||||
{
|
||||
EnqueueUpdate(razorProjectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.Exists(workspaceDirectoryPath))
|
||||
|
@ -115,11 +116,12 @@ internal partial class FileWatcherBasedRazorProjectInfoDriver : AbstractRazorPro
|
|||
case ChangeKind.AddOrUpdate:
|
||||
using (var stream = File.OpenRead(filePath))
|
||||
{
|
||||
var razorProjectInfo = await RazorProjectInfo
|
||||
.DeserializeFromAsync(stream, token)
|
||||
.ConfigureAwait(false);
|
||||
var razorProjectInfo = await TryDeserializeAsync(filePath, token).ConfigureAwait(false);
|
||||
|
||||
EnqueueUpdate(razorProjectInfo);
|
||||
if (razorProjectInfo is not null)
|
||||
{
|
||||
EnqueueUpdate(razorProjectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -155,4 +157,22 @@ internal partial class FileWatcherBasedRazorProjectInfoDriver : AbstractRazorPro
|
|||
EnqueueRemove(oldFilePath);
|
||||
EnqueueAddOrChange(newFilePath);
|
||||
}
|
||||
|
||||
private async ValueTask<RazorProjectInfo?> TryDeserializeAsync(string filePath, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = File.OpenRead(filePath);
|
||||
|
||||
return await RazorProjectInfo
|
||||
.DeserializeFromAsync(stream, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, $"Error occurred while reading and deserializing '{filePath}'");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче