Shell: Use JsonArray::append in save_to

We can convert it into a failable function here easily
This commit is contained in:
Cameron Youell 2023-04-17 16:02:41 +10:00 committed by Andreas Kling
parent ba38984a60
commit da305017de
Notes: sideshowbarker 2024-07-16 21:05:48 +09:00
2 changed files with 5 additions and 3 deletions

View file

@ -2348,7 +2348,7 @@ void Shell::kill_job(Job const* job, int sig)
}
}
void Shell::save_to(JsonObject& object)
ErrorOr<void> Shell::save_to(JsonObject& object)
{
Core::Object::save_to(object);
object.set("working_directory", cwd);
@ -2367,9 +2367,11 @@ void Shell::save_to(JsonObject& object)
job_object.set("running_time", job_entry.value->timer().elapsed());
job_object.set("command", job_entry.value->cmd());
job_object.set("is_running_in_background", job_entry.value->is_running_in_background());
job_objects.must_append(move(job_object));
TRY(job_objects.append(move(job_object)));
}
object.set("jobs", move(job_objects));
return {};
}
void Shell::possibly_print_error() const

View file

@ -402,7 +402,7 @@ private:
bool is_allowed_to_modify_termios(const AST::Command&) const;
// FIXME: Port to Core::Property
void save_to(JsonObject&);
ErrorOr<void> save_to(JsonObject&);
void bring_cursor_to_beginning_of_a_line() const;
Optional<int> resolve_job_spec(StringView);