diff --git a/src/command/value.cpp b/src/command/value.cpp index 66324724e3a481950bcf1f57b6dd7f60827ee0fa..bb137734afbcb4c8fc158ad7892d018e91f9fefc 100644 --- a/src/command/value.cpp +++ b/src/command/value.cpp @@ -222,21 +222,21 @@ namespace dynamicgraph { float Value::floatValue() const { float result; - if(type_ == FLOAT) - result = *((float*)value_); + if(FLOAT != type_) + throw ExceptionAbstract(ExceptionAbstract::TOOLS, + "value is not a float"); + result = *((float*)value_); return result; - throw ExceptionAbstract(ExceptionAbstract::TOOLS, - "value is not a float"); } double Value::doubleValue() const { double result; - if(type_ == DOUBLE) - result = *((double*)value_); + if(DOUBLE != type_) + throw ExceptionAbstract(ExceptionAbstract::TOOLS, + "value is not a double"); + result = *((double*)value_); return result; - throw ExceptionAbstract(ExceptionAbstract::TOOLS, - "value is not a double"); } std::string Value::stringValue() const