mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +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:
parent
664117564a
commit
2693745336
6 changed files with 38 additions and 21 deletions
|
@ -670,7 +670,7 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
return render_thumbnail(path);
|
||||
},
|
||||
|
||||
[this, path, weak_this](auto thumbnail_or_error) {
|
||||
[this, path, weak_this](auto thumbnail_or_error) -> ErrorOr<void> {
|
||||
if (thumbnail_or_error.is_error()) {
|
||||
s_thumbnail_cache.set(path, nullptr);
|
||||
dbgln("Failed to load thumbnail for {}: {}", path, thumbnail_or_error.error());
|
||||
|
@ -681,7 +681,7 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
// The model was destroyed, no need to update
|
||||
// progress or call any event handlers.
|
||||
if (weak_this.is_null())
|
||||
return;
|
||||
return {};
|
||||
|
||||
m_thumbnail_progress++;
|
||||
if (on_thumbnail_progress)
|
||||
|
@ -692,6 +692,7 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
}
|
||||
|
||||
did_update(UpdateFlag::DontInvalidateIndices);
|
||||
return {};
|
||||
});
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue