Line data Source code
1 : #include "rate.h" 2 : 3 : #include <string> 4 : 5 : namespace datadog { 6 : namespace tracing { 7 : 8 26490 : Expected<Rate> Rate::from(double value) { 9 26490 : if (value >= 0 && value <= 1) { 10 26475 : return Rate(value); 11 : } 12 : 13 15 : std::string message; 14 : message += 15 15 : "A rate must be no less than 0.0 and no more than 1.0, but we received: "; 16 15 : message += std::to_string(value); 17 15 : return Error{Error::RATE_OUT_OF_RANGE, std::move(message)}; 18 15 : } 19 : 20 : } // namespace tracing 21 : } // namespace datadog