From 2f7a40bd503c3228c68dcc02860174b528f6319b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 14 Nov 2025 11:18:33 -0800 Subject: [PATCH] Remove typed throws in some Ndb functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those are unused and it causes awkward implementations when different error types need to be used. Signed-off-by: Daniel D’Aquino --- nostrdb/Ndb+.swift | 4 ++-- nostrdb/Ndb.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nostrdb/Ndb+.swift b/nostrdb/Ndb+.swift index 79fc39c1..00b22beb 100644 --- a/nostrdb/Ndb+.swift +++ b/nostrdb/Ndb+.swift @@ -18,12 +18,12 @@ extension Ndb { /// - maxSimultaneousResults: Maximum number of initial results to return /// - Returns: AsyncStream of StreamItem events /// - Throws: NdbStreamError if subscription fails - func subscribe(filters: [NostrFilter], maxSimultaneousResults: Int = 1000) throws(NdbStreamError) -> AsyncStream { + func subscribe(filters: [NostrFilter], maxSimultaneousResults: Int = 1000) throws -> AsyncStream { let ndbFilters: [NdbFilter] do { ndbFilters = try filters.toNdbFilters() } catch { - throw .cannotConvertFilter(error) + throw NdbStreamError.cannotConvertFilter(error) } return try self.subscribe(filters: ndbFilters, maxSimultaneousResults: maxSimultaneousResults) } diff --git a/nostrdb/Ndb.swift b/nostrdb/Ndb.swift index e16daaa3..b171559d 100644 --- a/nostrdb/Ndb.swift +++ b/nostrdb/Ndb.swift @@ -710,22 +710,22 @@ class Ndb { } } - func subscribe(filters: [NdbFilter], maxSimultaneousResults: Int = 1000) throws(NdbStreamError) -> AsyncStream { - guard !self.is_closed else { throw .ndbClosed } + func subscribe(filters: [NdbFilter], maxSimultaneousResults: Int = 1000) throws -> AsyncStream { + guard !self.is_closed else { throw NdbStreamError.ndbClosed } - do { try Task.checkCancellation() } catch { throw .cancelled } + do { try Task.checkCancellation() } catch { throw NdbStreamError.cancelled } // CRITICAL: Create the subscription FIRST before querying to avoid race condition // This ensures that any events indexed after subscription but before query won't be missed let newEventsStream = ndbSubscribe(filters: filters) // Now fetch initial results after subscription is registered - guard let txn = NdbTxn(ndb: self) else { throw .cannotOpenTransaction } + guard let txn = NdbTxn(ndb: self) else { throw NdbStreamError.cannotOpenTransaction } // Use our safe wrapper instead of direct C function call let noteIds = try query(with: txn, filters: filters, maxResults: maxSimultaneousResults) - do { try Task.checkCancellation() } catch { throw .cancelled } + do { try Task.checkCancellation() } catch { throw NdbStreamError.cancelled } // Create a cascading stream that combines initial results with new events return AsyncStream { continuation in