Skip to content

Commit

Permalink
handle reader errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MattLichtenstein committed Nov 14, 2024
1 parent a42408f commit 9a9658c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions firefox-ios/Storage/Rust/RustPlaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public class RustPlaces: BookmarksHandler, HistoryMetadataObserver {
return deferred
}

@discardableResult
private func withReader<T>(
_ callback: @escaping(_ connection: PlacesReadConnection) throws -> T
) -> Deferred<Maybe<T>> {
Expand Down Expand Up @@ -203,11 +202,14 @@ public class RustPlaces: BookmarksHandler, HistoryMetadataObserver {
}

public func countBookmarksInTrees(folderGuids: [GUID], completion: @escaping (Result<Int, Error>) -> Void) {
withReader { connection in
do {
let count = try connection.countBookmarksInTrees(folderGuids: folderGuids)
let deferredResponse = withReader { connection in
return try connection.countBookmarksInTrees(folderGuids: folderGuids)
}

deferredResponse.upon { result in
if let count = result.successValue {
completion(.success(count))
} catch {
} else if let error = result.failureValue {
completion(.failure(error))
}
}
Expand Down

0 comments on commit 9a9658c

Please sign in to comment.