[backend] Improve logging for unknown activity types
This commit is contained in:
parent
ec561706d6
commit
333ef6f7cd
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
using Iceshrimp.Backend.Core.Federation.ActivityPub;
|
||||
using Iceshrimp.Backend.Core.Federation.ActivityStreams;
|
||||
using Iceshrimp.Backend.Core.Federation.ActivityStreams.Types;
|
||||
using Iceshrimp.Backend.Core.Middleware;
|
||||
using Iceshrimp.Backend.Core.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ProtoBuf;
|
||||
|
@ -22,7 +23,9 @@ public class InboxQueue {
|
|||
if (expanded == null) throw new Exception("Failed to expand ASObject");
|
||||
var obj = ASObject.Deserialize(expanded);
|
||||
if (obj == null) throw new Exception("Failed to deserialize ASObject");
|
||||
if (obj is not ASActivity activity) throw new NotImplementedException("Job data is not an ASActivity");
|
||||
if (obj is not ASActivity activity) {
|
||||
throw new GracefulException("Job data is not an ASActivity", $"Type: {obj.Type}");
|
||||
}
|
||||
|
||||
var apHandler = scope.GetRequiredService<ActivityHandlerService>();
|
||||
var logger = scope.GetRequiredService<ILogger<InboxQueue>>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Iceshrimp.Backend.Core.Configuration;
|
||||
using Iceshrimp.Backend.Core.Helpers;
|
||||
using Iceshrimp.Backend.Core.Middleware;
|
||||
using Iceshrimp.Backend.Core.Queues;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ProtoBuf;
|
||||
|
@ -98,7 +99,13 @@ public class JobQueue<T>(
|
|||
job.ExceptionSource = e.TargetSite?.DeclaringType?.FullName ?? "Unknown";
|
||||
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<QueueService>>();
|
||||
logger.LogError("Failed to process job in {queue} queue: {error}", name, e.Message);
|
||||
if (e is GracefulException { Details: not null } ce) {
|
||||
logger.LogError("Failed to process job in {queue} queue: {error} - {details}",
|
||||
name, ce.Message, ce.Details);
|
||||
}
|
||||
else {
|
||||
logger.LogError("Failed to process job in {queue} queue: {error}", name, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (job.Status is Job.JobStatus.Failed) {
|
||||
|
|
Loading…
Add table
Reference in a new issue