< Summary

Information
Class: TeleFlow.Annotations.ErrorAttribute<T>
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Errors/ErrorAttribute.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 49
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%

File(s)

/_/src/TeleFlow.Annotations/Errors/ErrorAttribute.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2
 3namespace TeleFlow.Annotations;
 4
 5/// <summary>
 6/// Marks a method as a Telegram handler error handler.
 7/// </summary>
 8[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 9[SuppressMessage(
 10    "Performance",
 11    "CA1813:Avoid unsealed attributes",
 12    Justification = "The non-generic catch-all error attribute is intentionally inherited by ErrorAttribute<TException>.
 13public class ErrorAttribute : TeleFlowAttribute
 14{
 15    /// <summary>
 16    /// Creates a catch-all handler error attribute.
 17    /// </summary>
 18    public ErrorAttribute()
 19    {
 20    }
 21
 22    internal ErrorAttribute(Type exceptionType)
 23    {
 24        ArgumentNullException.ThrowIfNull(exceptionType);
 25
 26        ExceptionType = exceptionType;
 27    }
 28
 29    /// <summary>
 30    /// Exception type handled by the method, or <see langword="null"/> for catch-all error handlers.
 31    /// </summary>
 32    public Type? ExceptionType { get; }
 33}
 34/// <summary>
 35/// Marks a method as handling a specific exception type raised by a Telegram handler.
 36/// </summary>
 37/// <typeparam name="TException">Exception type handled by the method.</typeparam>
 38[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 39public sealed class ErrorAttribute<TException> : ErrorAttribute
 40    where TException : Exception
 41{
 42    /// <summary>
 43    /// Creates a typed handler error attribute.
 44    /// </summary>
 45    public ErrorAttribute()
 11346        : base(typeof(TException))
 47    {
 11348    }
 49}

Methods/Properties

.ctor()