Applets/ResourceGraph: Propagate errors in JSON decoding
This commit is contained in:
parent
e46f08ff33
commit
74d1eb6502
Notes:
sideshowbarker
2024-07-17 21:45:03 +09:00
Author: https://github.com/creator1creeper1 Commit: https://github.com/SerenityOS/serenity/commit/74d1eb65027 Pull-request: https://github.com/SerenityOS/serenity/pull/11419
1 changed files with 8 additions and 2 deletions
|
@ -136,7 +136,10 @@ private:
|
|||
}
|
||||
|
||||
auto file_contents = m_proc_stat->read_all();
|
||||
auto json = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors();
|
||||
auto json_or_error = JsonValue::from_string(file_contents);
|
||||
if (json_or_error.is_error())
|
||||
return false;
|
||||
auto json = json_or_error.release_value();
|
||||
auto const& obj = json.as_object();
|
||||
total = obj.get("total_time").to_u64();
|
||||
idle = obj.get("idle_time").to_u64();
|
||||
|
@ -157,7 +160,10 @@ private:
|
|||
}
|
||||
|
||||
auto file_contents = m_proc_mem->read_all();
|
||||
auto json = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors();
|
||||
auto json_or_error = JsonValue::from_string(file_contents);
|
||||
if (json_or_error.is_error())
|
||||
return false;
|
||||
auto json = json_or_error.release_value();
|
||||
auto const& obj = json.as_object();
|
||||
unsigned kmalloc_allocated = obj.get("kmalloc_allocated").to_u32();
|
||||
unsigned kmalloc_available = obj.get("kmalloc_available").to_u32();
|
||||
|
|
Loading…
Add table
Reference in a new issue