changeset 1545:b89705af7a60

Use an actual exception for this (rather than checking only in some builds)
author Chris Cannam
date Mon, 01 Oct 2018 14:37:11 +0100
parents a7485c1bdba5
children 9c14dee72329
files base/RangeMapper.cpp
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/base/RangeMapper.cpp	Tue Sep 18 15:04:46 2018 +0100
+++ b/base/RangeMapper.cpp	Mon Oct 01 14:37:11 2018 +0100
@@ -20,6 +20,7 @@
 #include <cmath>
 
 #include <iostream>
+#include <stdexcept>
 
 LinearRangeMapper::LinearRangeMapper(int minpos, int maxpos,
                                      double minval, double maxval,
@@ -33,8 +34,12 @@
     m_inverted(inverted),
     m_labels(labels)
 {
-    assert(m_maxval != m_minval);
-    assert(m_maxpos != m_minpos);
+    if (m_maxval == m_minval) {
+        throw std::logic_error("LinearRangeMapper: maxval must differ from minval");
+    }
+    if (m_maxpos == m_minpos) {
+        throw std::logic_error("LinearRangeMapper: maxpos must differ from minpos");
+    }
 }
 
 int
@@ -101,7 +106,9 @@
 //              << maxval << ", minlog " << m_minlog << ", ratio " << m_ratio
 //              << ", unit " << unit << endl;
 
-    assert(m_maxpos != m_minpos);
+    if (m_maxpos == m_minpos) {
+        throw std::logic_error("LogRangeMapper: maxpos must differ from minpos");
+    }
 
     m_maxlog = (m_maxpos - m_minpos) / m_ratio + m_minlog;