diff --git a/src/QLNet/Cashflows/CashFlows.cs b/src/QLNet/Cashflows/CashFlows.cs index a36a5a5dd..98f5d3b63 100644 --- a/src/QLNet/Cashflows/CashFlows.cs +++ b/src/QLNet/Cashflows/CashFlows.cs @@ -294,9 +294,12 @@ private void checkSign() lastSign = thisSign; } } - Utils.QL_REQUIRE(signChanges > 0, () => - "the given cash flows cannot result in the given market " + - "price due to their sign"); + + if (signChanges <= 0) + { + Utils.QL_FAIL("the given cash flows cannot result in the given market " + + "price due to their sign", QLNetExceptionEnum.InvalidPriceSignException); + } } } class ZSpreadFinder : ISolver1d diff --git a/src/QLNet/Exceptions/QLNetExceptionEnum.cs b/src/QLNet/Exceptions/QLNetExceptionEnum.cs index 31e20778a..b8d361235 100644 --- a/src/QLNet/Exceptions/QLNetExceptionEnum.cs +++ b/src/QLNet/Exceptions/QLNetExceptionEnum.cs @@ -5,6 +5,7 @@ public enum QLNetExceptionEnum ArgumentException = 1, NotTradableException = 2, RootNotBracketException = 3, - MaxNumberFuncEvalExceeded = 4 + MaxNumberFuncEvalExceeded = 4, + InvalidPriceSignException = 5 } } diff --git a/src/QLNet/Utils.cs b/src/QLNet/Utils.cs index a65a37e57..c539d9386 100644 --- a/src/QLNet/Utils.cs +++ b/src/QLNet/Utils.cs @@ -137,6 +137,8 @@ public static void QL_FAIL(string message, QLNetExceptionEnum exEnum = QLNetExce throw new RootNotBracketException(message); case QLNetExceptionEnum.MaxNumberFuncEvalExceeded: throw new MaxNumberFuncEvalExceeded(message); + case QLNetExceptionEnum.InvalidPriceSignException: + throw new InvalidPriceSignException(message); } }