< Summary

Information
Class: Gravitas.CollisionHandling.CollisionNotificationExceptions
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Pairs/CollisionNotificationExceptions.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Capture(...)100%22100%
ThrowIfAny(...)100%44100%
ToException(...)100%44100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Pairs/CollisionNotificationExceptions.cs

#LineLine coverage
 1//=======================================================================
 2// CollisionNotificationExceptions.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Runtime.CompilerServices;
 10using System.Runtime.ExceptionServices;
 11using SwiftCollections;
 12
 13namespace Gravitas.CollisionHandling;
 14
 15/// <summary>Collects collision notification failures for reporting after dispatch.</summary>
 16internal static class CollisionNotificationExceptions
 17{
 18    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 19    internal static void Capture(ref SwiftList<Exception>? exceptions, Exception exception) =>
 4520        (exceptions ??= new SwiftList<Exception>(2)).Add(exception);
 21
 22    [MethodImpl(MethodImplOptions.NoInlining)]
 23    internal static void ThrowIfAny(SwiftList<Exception>? exceptions)
 24    {
 15957425        if (exceptions == null)
 15954226            return;
 27
 3228        if (exceptions.Count == 1)
 2929            ExceptionDispatchInfo.Capture(exceptions[0]).Throw();
 30
 331        throw new AggregateException(exceptions);
 32    }
 33
 34    internal static Exception? ToException(SwiftList<Exception>? exceptions)
 35    {
 18936        if (exceptions == null)
 18337            return null;
 38
 639        return exceptions.Count == 1
 640            ? exceptions[0]
 641            : new AggregateException(exceptions);
 42    }
 43}