lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master ac2e25b 03/24: Expunge an unwanted exception


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ac2e25b 03/24: Expunge an unwanted exception class
Date: Wed, 30 Dec 2020 18:46:56 -0500 (EST)

branch: master
commit ac2e25bb58c6d94f5306f4a89fac1c62225d42b2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Expunge an unwanted exception class
    
    The GPT server has numerous exception classes of its own. Expunged the
    "product rule violated" exception, which was unique in that it was used
    outside the server's main TU (because the conditions for throwing it
    could not readily be detected in that TU). It harmfully obstructed
    merging BasicValues::GPTServerInit() into BasicValues::Init().
    
    Left the other special exception classes alone because they're self-
    contained and harmless, though overwrought. The original intention was
    to catch numerous specific exceptions, translate them to a numeric error
    code, and augment their what() messages with unique contract numbers,
    for an lmi-based client-server tax system; but no client was ever
    finished.
---
 Makefile.am        |  1 -
 ihs_basicval.cpp   | 25 ++++++++++++++++---------
 ihs_server7702.cpp | 19 +++++++++----------
 ihs_x_type.hpp     | 39 ---------------------------------------
 4 files changed, 25 insertions(+), 59 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 62b10ea..d8545b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1347,7 +1347,6 @@ noinst_HEADERS = \
     ihs_irc7702.hpp \
     ihs_irc7702a.hpp \
     ihs_server7702.hpp \
-    ihs_x_type.hpp \
     illustration_document.hpp \
     illustration_view.hpp \
     illustrator.hpp \
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index d9a9dee..be6a2f2 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -252,7 +252,6 @@ void BasicValues::Init()
 }
 
 //============================================================================
-#include "ihs_x_type.hpp"               // x_product_rule_violated TAXATION !! 
remove later
 // TODO ??  Not for general use--use for GPT server only, for now. TAXATION !! 
refactor later
 void BasicValues::GPTServerInit()
 {
@@ -288,17 +287,25 @@ void BasicValues::GPTServerInit()
 
     if(IssueAge < database().query<int>(DB_MinIssAge))
         {
-        throw x_product_rule_violated
-            (
-            std::string("Issue age less than minimum")
-            );
+        alarum()
+            << "Issue age "
+            << IssueAge
+            << " less than minimum "
+            << database().query<int>(DB_MinIssAge)
+            << '.'
+            << LMI_FLUSH
+            ;
         }
     if(database().query<int>(DB_MaxIssAge) < IssueAge)
         {
-        throw x_product_rule_violated
-            (
-            std::string("Issue age greater than maximum")
-            );
+        alarum()
+            << "Issue age "
+            << IssueAge
+            << " greater than maximum "
+            << database().query<int>(DB_MaxIssAge)
+            << '.'
+            << LMI_FLUSH
+            ;
         }
 //  lingo_.reset(new lingo(AddDataDir(product().datum("LingoFilename"))));
 //  FundData_.reset(new FundData(AddDataDir(product().datum("FundFilename"))));
diff --git a/ihs_server7702.cpp b/ihs_server7702.cpp
index ebfd64b..e1ce60a 100644
--- a/ihs_server7702.cpp
+++ b/ihs_server7702.cpp
@@ -32,7 +32,6 @@
 #include "fenv_lmi.hpp"
 #include "gpt_input.hpp"
 #include "ihs_irc7702.hpp"
-#include "ihs_x_type.hpp"
 
 #include <exception>
 
@@ -41,10 +40,10 @@ enum
     ,precision_changed                      = 0x0002
     ,implausible_input                      = 0x0004
     ,inconsistent_input                     = 0x0008
-    ,product_rule_violated                  = 0x0010
-    ,adjustable_event_forbidden_at_issue    = 0x0020
-    ,guideline_negative                     = 0x0040
-    ,misstatement_of_age_or_gender          = 0x0080
+    ,adjustable_event_forbidden_at_issue    = 0x0010
+    ,guideline_negative                     = 0x0020
+    ,misstatement_of_age_or_gender          = 0x0040
+    ,runtime_error                          = 0x0080
     };
 
 //============================================================================
@@ -116,11 +115,6 @@ void Server7702::Process()
         Output.Status |= inconsistent_input;
         warning() << Output.ContractNumber << " error: " << e.what() << 
LMI_FLUSH;
         }
-    catch(x_product_rule_violated const& e)
-        {
-        Output.Status |= product_rule_violated;
-        warning() << Output.ContractNumber << " error: " << e.what() << 
LMI_FLUSH;
-        }
     catch(server7702_adjustable_event_forbidden_at_issue const& e)
         {
         Output.Status |= adjustable_event_forbidden_at_issue;
@@ -141,6 +135,11 @@ void Server7702::Process()
         Output.Status |= implausible_input; // TODO ?? can we be more specific?
         warning() << Output.ContractNumber << " error: " << e.what() << 
LMI_FLUSH;
         }
+    catch(std::runtime_error const& e)
+        {
+        Output.Status |= runtime_error;
+        warning() << Output.ContractNumber << " error: " << e.what() << 
LMI_FLUSH;
+        }
 
     // Unknown error
     catch(std::exception const& e)
diff --git a/ihs_x_type.hpp b/ihs_x_type.hpp
deleted file mode 100644
index c109757..0000000
--- a/ihs_x_type.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// GPT server exception type.
-//
-// Copyright (C) 1998, 2001, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Gregory W. Chicares.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-//
-// https://savannah.nongnu.org/projects/lmi
-// email: <gchicares@sbcglobal.net>
-// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-
-#ifndef ihs_x_type_hpp
-#define ihs_x_type_hpp
-
-#include "config.hpp"
-
-#include <stdexcept>
-#include <string>
-
-class x_product_rule_violated
-    :public std::runtime_error
-{
-  public:
-    x_product_rule_violated(std::string const& what_arg)
-    :std::runtime_error("Product rule violated: " + what_arg)
-    {}
-};
-
-#endif // ihs_x_type_hpp



reply via email to

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