This commit is contained in:
Mark McDowall 2026-05-03 16:15:36 +00:00 committed by GitHub
commit 6bc67fb809
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 3 deletions

View file

@ -40,9 +40,13 @@ public void MarkAsFailed(int historyId, string message, string source = null, bo
if (downloadId.IsNullOrWhiteSpace())
{
PublishDownloadFailedEvent(history, new List<int> { history.EpisodeId }, message, source, skipRedownload: skipRedownload);
if (history.EventType == EpisodeHistoryEventType.Grabbed)
{
PublishDownloadFailedEvent(history, new List<int> { history.EpisodeId }, message, source, skipRedownload: skipRedownload);
return;
}
return;
throw new InvalidOperationException("Unable to mark download as failed, history item was not grabbed and has no download ID");
}
var grabbedHistory = new List<EpisodeHistory>();
@ -57,7 +61,12 @@ public void MarkAsFailed(int historyId, string message, string source = null, bo
grabbedHistory.AddRange(GetGrabbedHistory(downloadId));
grabbedHistory = grabbedHistory.DistinctBy(h => h.Id).ToList();
PublishDownloadFailedEvent(history, GetEpisodeIds(grabbedHistory), message, source);
if (grabbedHistory.Any())
{
PublishDownloadFailedEvent(grabbedHistory.First(), GetEpisodeIds(grabbedHistory), message, source);
}
throw new InvalidOperationException("Unable to mark download as failed, no grabbed history available");
}
public void MarkAsFailed(TrackedDownload trackedDownload, string message, string source = null, bool skipRedownload = false)
@ -68,6 +77,8 @@ public void MarkAsFailed(TrackedDownload trackedDownload, string message, string
{
PublishDownloadFailedEvent(history.First(), GetEpisodeIds(history), message ?? "Manually marked as failed", source, trackedDownload, skipRedownload: skipRedownload);
}
throw new InvalidOperationException("Unable to mark download as failed, no grabbed history available");
}
public void Check(TrackedDownload trackedDownload)

View file

@ -1,3 +1,4 @@
using System;
using System.Data.SQLite;
using System.Net;
using System.Threading.Tasks;
@ -76,6 +77,12 @@ public async Task HandleException(HttpContext context)
_logger.Error(sqLiteException, "[{0} {1}]", context.Request.Method, context.Request.Path);
}
else if (exception is InvalidOperationException invalidOperationException)
{
_logger.Warn(invalidOperationException, "[{0} {1}]", context.Request.Method, context.Request.Path);
statusCode = HttpStatusCode.BadRequest;
}
else
{
_logger.Fatal(exception, "Request Failed. {0} {1}", context.Request.Method, context.Request.Path);