Log error when attempting to deserialize IMessageBase in MessageBaseConverter

This commit is contained in:
Thorsten Sommer 2025-12-28 13:59:18 +01:00
parent 139c4fa036
commit 110932548e
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -13,11 +13,14 @@ namespace AIStudio.Provider;
/// </remarks>
public sealed class MessageBaseConverter : JsonConverter<IMessageBase>
{
public override IMessageBase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
private static readonly ILogger<MessageBaseConverter> LOGGER = Program.LOGGER_FACTORY.CreateLogger<MessageBaseConverter>();
public override IMessageBase? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
// Deserialization is not needed for request objects, as messages are only serialized
// when sending requests to LLM providers.
throw new NotImplementedException("Deserializing IMessageBase is not supported. This converter is only used for serializing request messages.");
LOGGER.LogError("Deserializing IMessageBase is not supported. This converter is only used for serializing request messages.");
return null;
}
public override void Write(Utf8JsonWriter writer, IMessageBase value, JsonSerializerOptions options)