< Summary

Information
Class: TeleFlow.Telegram.TelegramUpdateDecodeFailure
Assembly: TeleFlow.Telegram.Client
File(s): /_/src/TeleFlow.Telegram.Client/TelegramUpdateDecodeFailure.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 59
Line coverage: 66.6%
Branch coverage
33%
Covered branches: 1
Total branches: 3
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)33.33%3375%
ToString()100%210%

File(s)

/_/src/TeleFlow.Telegram.Client/TelegramUpdateDecodeFailure.cs

#LineLine coverage
 1namespace TeleFlow.Telegram;
 2
 3/// <summary>
 4/// Describes one syntactically valid Telegram update that could not be mapped to the installed schema.
 5/// Applications can persist the raw payload before explicitly allowing the transport to skip it.
 6/// </summary>
 7public sealed class TelegramUpdateDecodeFailure
 8{
 9    /// <summary>
 10    /// Creates evidence for one update schema failure without exposing the raw payload through <see cref="ToString"/>.
 11    /// </summary>
 12    public TelegramUpdateDecodeFailure(
 13        TelegramUpdateTransport transport,
 14        long updateId,
 15        string rawPayloadJson,
 16        string payloadSha256,
 17        TelegramUpdateDecodeException exception)
 18    {
 819        ArgumentException.ThrowIfNullOrWhiteSpace(rawPayloadJson);
 820        ArgumentException.ThrowIfNullOrWhiteSpace(payloadSha256);
 821        ArgumentNullException.ThrowIfNull(exception);
 22
 823        if (exception.UpdateId != updateId)
 24        {
 025            throw new ArgumentException("The decode exception belongs to a different Telegram update.", nameof(exception
 26        }
 27
 828        if (!string.Equals(exception.PayloadSha256, payloadSha256, StringComparison.Ordinal))
 29        {
 030            throw new ArgumentException("The decode exception contains a different payload fingerprint.", nameof(excepti
 31        }
 32
 33        Transport = transport;
 34        UpdateId = updateId;
 35        RawPayloadJson = rawPayloadJson;
 36        PayloadSha256 = payloadSha256;
 37        Exception = exception;
 838    }
 39
 40    /// <summary>Gets the transport that received the incompatible update.</summary>
 41    public TelegramUpdateTransport Transport { get; }
 42
 43    /// <summary>Gets the Telegram update identifier used for acknowledgement ordering.</summary>
 44    public long UpdateId { get; }
 45
 46    /// <summary>Gets the complete raw JSON update for durable quarantine.</summary>
 47    public string RawPayloadJson { get; }
 48
 49    /// <summary>Gets the lowercase SHA-256 fingerprint of <see cref="RawPayloadJson"/>.</summary>
 50    public string PayloadSha256 { get; }
 51
 52    /// <summary>Gets the structured schema decode exception.</summary>
 53    public TelegramUpdateDecodeException Exception { get; }
 54
 55    public override string ToString()
 56    {
 057        return $"Telegram update {UpdateId} failed schema decoding on {Transport}; payload_sha256={PayloadSha256}.";
 58    }
 59}