Replace use of std::runtime_error with std::invalid_argument where that makes sense. Thanks to Bjorn Reese for reporting this.