Remove typed throws in some Ndb functions

Those are unused and it causes awkward implementations when different
error types need to be used.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-11-14 11:18:33 -08:00
parent 498af9bc3a
commit 2f7a40bd50
2 changed files with 7 additions and 7 deletions

View File

@@ -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<StreamItem> {
func subscribe(filters: [NostrFilter], maxSimultaneousResults: Int = 1000) throws -> AsyncStream<StreamItem> {
let ndbFilters: [NdbFilter]
do {
ndbFilters = try filters.toNdbFilters()
} catch {
throw .cannotConvertFilter(error)
throw NdbStreamError.cannotConvertFilter(error)
}
return try self.subscribe(filters: ndbFilters, maxSimultaneousResults: maxSimultaneousResults)
}

View File

@@ -710,22 +710,22 @@ class Ndb {
}
}
func subscribe(filters: [NdbFilter], maxSimultaneousResults: Int = 1000) throws(NdbStreamError) -> AsyncStream<StreamItem> {
guard !self.is_closed else { throw .ndbClosed }
func subscribe(filters: [NdbFilter], maxSimultaneousResults: Int = 1000) throws -> AsyncStream<StreamItem> {
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<StreamItem> { continuation in