Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/SentenceStudio.Api/ChannelEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SentenceStudio.Services;
using SentenceStudio.Shared.Models;

Expand Down Expand Up @@ -111,7 +112,8 @@ private static async Task<IResult> TriggerCheck(
string id,
ClaimsPrincipal user,
[FromServices] ChannelMonitorService channelService,
[FromServices] VideoImportPipelineService pipelineService)
[FromServices] VideoImportPipelineService pipelineService,
[FromServices] ILoggerFactory loggerFactory)
{
var userProfileId = user.FindFirstValue("user_profile_id");
if (string.IsNullOrEmpty(userProfileId))
Expand Down Expand Up @@ -155,7 +157,9 @@ private static async Task<IResult> TriggerCheck(
}
catch (Exception ex)
{
// Logging happens inside the pipeline service
var logger = loggerFactory.CreateLogger(nameof(ChannelEndpoints));
logger.LogError(ex, "Unhandled exception in import pipeline for import {ImportId}", import.Id);
await pipelineService.FailImportAsync(import, ex.Message);
}
});

Expand Down
15 changes: 11 additions & 4 deletions src/SentenceStudio.Api/ImportEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SentenceStudio.Services;
using SentenceStudio.Shared.Models;

Expand Down Expand Up @@ -55,7 +56,8 @@ private static async Task<IResult> GetImport(
private static async Task<IResult> StartImport(
[FromBody] StartImportRequest request,
ClaimsPrincipal user,
[FromServices] VideoImportPipelineService pipelineService)
[FromServices] VideoImportPipelineService pipelineService,
[FromServices] ILoggerFactory loggerFactory)
{
var userProfileId = user.FindFirstValue("user_profile_id");
if (string.IsNullOrEmpty(userProfileId))
Expand All @@ -82,7 +84,9 @@ private static async Task<IResult> StartImport(
}
catch (Exception ex)
{
// Logging happens inside the pipeline service
var logger = loggerFactory.CreateLogger(nameof(ImportEndpoints));
logger.LogError(ex, "Unhandled exception in import pipeline for import {ImportId}", import.Id);
await pipelineService.FailImportAsync(import, ex.Message);
}
});

Expand All @@ -97,7 +101,8 @@ private static async Task<IResult> StartImport(
private static async Task<IResult> RetryImport(
string id,
ClaimsPrincipal user,
[FromServices] VideoImportPipelineService pipelineService)
[FromServices] VideoImportPipelineService pipelineService,
[FromServices] ILoggerFactory loggerFactory)
{
var userProfileId = user.FindFirstValue("user_profile_id");
if (string.IsNullOrEmpty(userProfileId))
Expand Down Expand Up @@ -132,7 +137,9 @@ private static async Task<IResult> RetryImport(
}
catch (Exception ex)
{
// Logging happens inside the pipeline service
var logger = loggerFactory.CreateLogger(nameof(ImportEndpoints));
logger.LogError(ex, "Unhandled exception in import pipeline for import {ImportId}", import.Id);
await pipelineService.FailImportAsync(import, ex.Message);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private async Task UpdateStatusAsync(VideoImport import, VideoImportStatus statu
_logger.LogDebug("Import {Id} → {Status}", import.Id, status);
}

private async Task FailImportAsync(VideoImport import, string errorMessage)
public async Task FailImportAsync(VideoImport import, string errorMessage)
{
import.Status = VideoImportStatus.Failed;
import.ErrorMessage = errorMessage;
Expand Down
Loading