1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

AK: Make string-to-number conversion helpers return Optional

Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
This commit is contained in:
Andreas Kling 2020-06-12 21:07:52 +02:00
parent 15f4043a7a
commit fdfda6dec2
55 changed files with 354 additions and 455 deletions

View file

@ -77,13 +77,13 @@ void Job::on_socket_connected()
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
}
bool ok;
m_status = parts[0].to_uint(ok);
if (!ok) {
auto status = parts[0].to_uint();
if (!status.has_value()) {
fprintf(stderr, "Job: Expected numeric status code\n");
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
}
m_status = status.value();
m_meta = parts[1];
if (m_status >= 10 && m_status < 20) {