Error message
This commit is contained in:
@@ -25,6 +25,10 @@ namespace Musify.Domain.Entities
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool IsPending => JobState == JobState.Pending;
|
public bool IsPending => JobState == JobState.Pending;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MaxLength(512)]
|
||||||
|
public string ErrorMessage { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Musify.Infrastructure.Messaging.Consumers
|
|||||||
var sourceImageResult = await GetSourceImageAsync(message.BucketName, message.KeyName, cancellationToken);
|
var sourceImageResult = await GetSourceImageAsync(message.BucketName, message.KeyName, cancellationToken);
|
||||||
if (!sourceImageResult.IsSuccess)
|
if (!sourceImageResult.IsSuccess)
|
||||||
{
|
{
|
||||||
MarkAllAsFailed(jobOperations);
|
MarkAllAsFailed(jobOperations, $"Failed to retrieve source image from storage, ResultState: {sourceImageResult.Status}");
|
||||||
await database.SaveChangesAsync(cancellationToken);
|
await database.SaveChangesAsync(cancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -147,11 +147,12 @@ namespace Musify.Infrastructure.Messaging.Consumers
|
|||||||
|
|
||||||
if (!resizedPictureResult.IsSuccess)
|
if (!resizedPictureResult.IsSuccess)
|
||||||
{
|
{
|
||||||
|
var errorMessage = string.Join("; ", resizedPictureResult.Errors);
|
||||||
logger.LogError("Failed to resize picture for JobOperationId={JobOperationId}. Error: {ErrorMessage}",
|
logger.LogError("Failed to resize picture for JobOperationId={JobOperationId}. Error: {ErrorMessage}",
|
||||||
jobOperation.Id,
|
jobOperation.Id,
|
||||||
string.Join("; ", resizedPictureResult.Errors));
|
errorMessage);
|
||||||
|
|
||||||
MarkAsFailed(jobOperation);
|
MarkAsFailed(jobOperation, errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +165,12 @@ namespace Musify.Infrastructure.Messaging.Consumers
|
|||||||
|
|
||||||
if (!saveResult.IsSuccess)
|
if (!saveResult.IsSuccess)
|
||||||
{
|
{
|
||||||
|
var errorMessage = string.Join("; ", saveResult.Errors);
|
||||||
logger.LogError("Failed to upload resized picture for JobOperationId={JobOperationId}. Error: {ErrorMessage}",
|
logger.LogError("Failed to upload resized picture for JobOperationId={JobOperationId}. Error: {ErrorMessage}",
|
||||||
jobOperation.Id,
|
jobOperation.Id,
|
||||||
string.Join("; ", saveResult.Errors));
|
errorMessage);
|
||||||
|
|
||||||
MarkAsFailed(jobOperation);
|
MarkAsFailed(jobOperation, errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,22 +186,23 @@ namespace Musify.Infrastructure.Messaging.Consumers
|
|||||||
operationItem.Item.Height,
|
operationItem.Item.Height,
|
||||||
operationItem.Item.SaveOnRoute);
|
operationItem.Item.SaveOnRoute);
|
||||||
|
|
||||||
MarkAsFailed(jobOperation);
|
MarkAsFailed(jobOperation, exception.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MarkAllAsFailed(IEnumerable<JobOperationItem> jobOperations)
|
private static void MarkAllAsFailed(IEnumerable<JobOperationItem> jobOperations, string errorMessage)
|
||||||
{
|
{
|
||||||
foreach (var operationItem in jobOperations)
|
foreach (var operationItem in jobOperations)
|
||||||
{
|
{
|
||||||
MarkAsFailed(operationItem.JobOperation);
|
MarkAsFailed(operationItem.JobOperation, errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MarkAsFailed(JobOperation jobOperation)
|
private static void MarkAsFailed(JobOperation jobOperation, string errorMessage)
|
||||||
{
|
{
|
||||||
jobOperation.JobState = JobState.Failed;
|
jobOperation.JobState = JobState.Failed;
|
||||||
jobOperation.FinishedAt = DateTime.UtcNow;
|
jobOperation.FinishedAt = DateTime.UtcNow;
|
||||||
|
jobOperation.ErrorMessage = errorMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user