1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 10:27:36 +00:00

LibThreading+Everywhere: Support returning error from BackgroundAction

This patch allows returning an `Error` from the `on_complete` callback
in `BackgroundAction`.

It also adds a custom callback to manage errors returned during its
execution.
This commit is contained in:
Lucas CHOLLET 2022-12-12 23:34:28 +01:00 committed by Linus Groh
parent 664117564a
commit 2693745336
6 changed files with 38 additions and 21 deletions

View file

@ -144,8 +144,9 @@ void FileProvider::query(DeprecatedString const& query, Function<void(NonnullRef
}
return results;
},
[on_complete = move(on_complete)](auto results) {
[on_complete = move(on_complete)](auto results) -> ErrorOr<void> {
on_complete(move(results));
return {};
});
}
@ -192,8 +193,9 @@ void FileProvider::build_filesystem_cache()
dbgln("Built cache in {} ms", timer.elapsed());
return 0;
},
[this](auto) {
[this](auto) -> ErrorOr<void> {
m_building_cache = false;
return {};
});
}