From b4db734b7ee703ac4437732c387e3b4d7fe90631 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 01:40:51 +0100 Subject: [PATCH] PainBoxSession.SetIntensity refuses a non-finite or negative level Co-Authored-By: Claude Sonnet 5.5 --- src/BadDay.Core/PainBoxSession.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BadDay.Core/PainBoxSession.cs b/src/BadDay.Core/PainBoxSession.cs index 889e723..25f0cde 100644 --- a/src/BadDay.Core/PainBoxSession.cs +++ b/src/BadDay.Core/PainBoxSession.cs @@ -62,8 +62,12 @@ public sealed class PainBoxSession /// True from the tick the deliberate withdrawal begins. public bool Withdrew { get; private set; } - /// Sets the box intensity the ramp scales; it takes effect on the next . - public void SetIntensity(double level) => _box.Level = level; + /// Sets the box intensity the ramp scales; it takes effect on the next . Refuses a non-finite or negative level. + public void SetIntensity(double level) + { + if (!double.IsFinite(level) || level < 0.0) throw new ArgumentOutOfRangeException(nameof(level), level, "The box intensity is finite and not negative."); + _box.Level = level; + } /// Switches the box off from the next tick; the check then ends the run if the will still holds. public void SwitchOff() => _box.SwitchOff(TickIndex);