Skip to content

Commit 1b1aa12

Browse files
committed
feat(abstractions): add policy evaluation exceptions
1 parent 97f4adc commit 1b1aa12

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace ModularityKit.Mutator.Abstractions.Exceptions;
2+
3+
/// <summary>
4+
/// Exception thrown when a policy evaluation fails before producing a decision.
5+
/// </summary>
6+
/// <remarks>
7+
/// Initializes a new instance of <see cref="PolicyEvaluationException"/>.
8+
/// </remarks>
9+
/// <param name="policyName">The policy name.</param>
10+
/// <param name="message">Human-readable description of the failure.</param>
11+
/// <param name="innerException">The underlying failure.</param>
12+
public class PolicyEvaluationException(string policyName, string message, Exception? innerException = null)
13+
: MutationException(message, innerException ?? new Exception(message))
14+
{
15+
16+
/// <summary>
17+
/// The name of the policy that failed.
18+
/// </summary>
19+
public string PolicyName { get; } = policyName;
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace ModularityKit.Mutator.Abstractions.Exceptions;
2+
3+
/// <summary>
4+
/// Exception thrown when policy evaluation exceeds the configured timeout.
5+
/// </summary>
6+
/// <remarks>
7+
/// Initializes new instance of <see cref="PolicyEvaluationTimeoutException"/>.
8+
/// </remarks>
9+
/// <param name="policyName">The policy name.</param>
10+
/// <param name="timeout">The configured timeout.</param>
11+
public sealed class PolicyEvaluationTimeoutException(string policyName, TimeSpan timeout) : PolicyEvaluationException(
12+
policyName,
13+
$"Policy '{policyName}' evaluation timed out after {timeout.TotalSeconds:0.###}s.")
14+
{
15+
/// <summary>
16+
/// The configured timeout for policy evaluation.
17+
/// </summary>
18+
public TimeSpan Timeout { get; } = timeout;
19+
}

0 commit comments

Comments
 (0)