From 7a4bc3e6d31b3006d90f1611948779a61a5eba9e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 30 Apr 2013 11:45:28 +0200 Subject: [PATCH] eoRealInterval better error handling Replace a logic exception in eoRealInterval by an assert. Add a warning in debug mode when the range is null. --- eo/src/utils/eoRealBounds.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 47c061005..a41646d47 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -27,6 +27,7 @@ #ifndef _eoRealBounds_h #define _eoRealBounds_h +#include #include // std::exceptions! #include @@ -226,10 +227,14 @@ public : */ eoRealInterval(double _min=0, double _max=1) : repMinimum(_min), repMaximum(_max), repRange(_max-_min) - { - if (repRange<=0) - throw std::logic_error("Void range in eoRealBounds"); - } + { + assert( repRange >= 0 ); +#ifndef NDEBUG + if( repRange == 0 ) { + eo::log << eo::warnings << "Null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; + } +#endif + } // accessors virtual double minimum() const { return repMinimum; }