mirror of https://github.com/OpenTTD/OpenTTD
Fix d1463f415f: Wrong type of exception thrown by invalid string parameters.
`FormatString()` only catches `std::out_of_range`, but `GetNextParameter()` threw `std::runtime_error`.pull/12954/head
parent
3bfd9de68d
commit
719d063bd4
|
@ -94,7 +94,7 @@ public:
|
||||||
const auto ¶m = GetNextParameterReference();
|
const auto ¶m = GetNextParameterReference();
|
||||||
const uint64_t *data = std::get_if<uint64_t>(¶m.data);
|
const uint64_t *data = std::get_if<uint64_t>(¶m.data);
|
||||||
if (data != nullptr) return static_cast<T>(*data);
|
if (data != nullptr) return static_cast<T>(*data);
|
||||||
throw std::runtime_error("Attempt to read string parameter as integer");
|
throw std::out_of_range("Attempt to read string parameter as integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
const auto ¶m = GetNextParameterReference();
|
const auto ¶m = GetNextParameterReference();
|
||||||
const std::string *data = std::get_if<std::string>(¶m.data);
|
const std::string *data = std::get_if<std::string>(¶m.data);
|
||||||
if (data != nullptr) return data->c_str();
|
if (data != nullptr) return data->c_str();
|
||||||
throw std::runtime_error("Attempt to read integer parameter as string");
|
throw std::out_of_range("Attempt to read integer parameter as string");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue