lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master d28f769 7/9: Improve certain error messages


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d28f769 7/9: Improve certain error messages
Date: Thu, 12 Jul 2018 13:12:58 -0400 (EDT)

branch: master
commit d28f769b6231fe9eb459d8d0281a30a77f314049
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Improve certain error messages
    
    years_and_months_since() throws an exception if its second argument
    precedes its first. That's appropriate, but the error message may
    confuse end users. Therefore, added explicit tests that display more
    helpful messages before calls to years_and_months_since().
    
    Rewrote the off-monthiversary error message to make it clearer and
    more informative, explicitly explaining that inforce values as of one
    date don't equal inforce values as of a different date.
---
 input_harmonization.cpp | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/input_harmonization.cpp b/input_harmonization.cpp
index 32228e2..62661e3 100644
--- a/input_harmonization.cpp
+++ b/input_harmonization.cpp
@@ -1091,6 +1091,18 @@ void Input::set_solve_durations()
 
 void Input::set_inforce_durations_from_dates(std::ostream& os)
 {
+    if(InforceAsOfDate.value() < EffectiveDate.value())
+        {
+        os
+            << "Input inforce-as-of date, "
+            << InforceAsOfDate.value().str()
+            << ", precedes the "
+            << EffectiveDate.value().str()
+            << " effective date."
+            << LMI_FLUSH
+            ;
+        }
+
     std::pair<int,int> ym0 = years_and_months_since
         (EffectiveDate  .value()
         ,InforceAsOfDate.value()
@@ -1099,6 +1111,20 @@ void 
Input::set_inforce_durations_from_dates(std::ostream& os)
     InforceYear  = ym0.first;
     InforceMonth = ym0.second;
 
+    if(InforceAsOfDate.value() < LastMaterialChangeDate.value())
+        {
+        os
+            << "Input inforce-as-of date, "
+            << InforceAsOfDate.value().str()
+            << ", precedes the "
+            << LastMaterialChangeDate.value().str()
+            << " last material change date."
+            << LMI_FLUSH
+            ;
+        }
+    // Somewhat dubiously, force the issue.
+    LastMaterialChangeDate = std::min(LastMaterialChangeDate, InforceAsOfDate);
+
     std::pair<int,int> ym1 = years_and_months_since
         (LastMaterialChangeDate.value()
         ,InforceAsOfDate       .value()
@@ -1119,7 +1145,7 @@ void 
Input::set_inforce_durations_from_dates(std::ostream& os)
             << "Input inforce-as-of date, "
             << InforceAsOfDate.value().str()
             << ", is not an exact monthiversary date."
-            << "\nIt must change to "
+            << "\nIt would be interpreted as "
             << expected.str()
             << ", which is "
             << InforceYear
@@ -1128,11 +1154,11 @@ void 
Input::set_inforce_durations_from_dates(std::ostream& os)
             << " full months"
             << "\nafter the "
             << EffectiveDate.value().str()
-            << " effective date."
+            << " effective date, but inforce values as of that date"
+            << " would be different."
             << LMI_FLUSH
             ;
         InforceAsOfDate = expected;
-        LastMaterialChangeDate = std::min(LastMaterialChangeDate, 
InforceAsOfDate);
         }
 
     if



reply via email to

[Prev in Thread] Current Thread [Next in Thread]