mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 10:08:42 +03:00
feat: handle-error minor improvments (#25288)
* feat: handle-error minor improvments * review comments * Update web/src/lib/utils/handle-error.ts Co-authored-by: Jason Rasmussen <jason@rasm.me> --------- Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
|
||||
/**
|
||||
* Tracks the state of asynchronous invocations to handle race conditions and stale operations.
|
||||
* This class helps manage concurrent operations by tracking which invocations are active
|
||||
@@ -51,10 +53,12 @@ export class InvocationTracker {
|
||||
return this.invocationsStarted !== this.invocationsEnded;
|
||||
}
|
||||
|
||||
async invoke<T>(invocable: () => Promise<T>) {
|
||||
async invoke<T>(invocable: () => Promise<T>, localizedMessage: string) {
|
||||
const invocation = this.startInvocation();
|
||||
try {
|
||||
return await invocable();
|
||||
} catch (error: unknown) {
|
||||
handleError(error, localizedMessage);
|
||||
} finally {
|
||||
invocation.endInvocation();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user