diff --git a/urdf_model/include/urdf_model/color.h b/urdf_model/include/urdf_model/color.h index 505d9a6..fec8ae0 100644 --- a/urdf_model/include/urdf_model/color.h +++ b/urdf_model/include/urdf_model/color.h @@ -73,13 +73,13 @@ class Color { try { - rgba.push_back(std::stof(pieces[i])); + double piece = strToDouble(pieces[i].c_str()); + if ((piece < 0) || (piece > 1)) + throw ParseError("Component [" + pieces[i] + "] is outside the valid range for colors [0, 1]"); + rgba.push_back(piece); } - catch (std::invalid_argument &/*e*/) { - return false; - } - catch (std::out_of_range &/*e*/) { - return false; + catch (std::runtime_error &/*e*/) { + throw ParseError("Unable to parse component [" + pieces[i] + "] to a double (while parsing a color value)"); } } }