Skip to content

Commit

Permalink
Added a new QLNet Exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
amaggiulli committed Aug 16, 2019
1 parent ac2ca38 commit 9633df8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/QLNet/Cashflows/CashFlows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/QLNet/Exceptions/QLNetExceptionEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum QLNetExceptionEnum
ArgumentException = 1,
NotTradableException = 2,
RootNotBracketException = 3,
MaxNumberFuncEvalExceeded = 4
MaxNumberFuncEvalExceeded = 4,
InvalidPriceSignException = 5
}
}
2 changes: 2 additions & 0 deletions src/QLNet/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 9633df8

Please sign in to comment.