From e8ed3ac08f37dd047b62d1a400dadac3a73dea0d Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Fri, 14 Mar 2025 08:09:02 -0500 Subject: [PATCH] Throw error rather than return `null` --- src/lib/data_structures/publication_tree.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/data_structures/publication_tree.ts b/src/lib/data_structures/publication_tree.ts index bac54a0..1cdbe16 100644 --- a/src/lib/data_structures/publication_tree.ts +++ b/src/lib/data_structures/publication_tree.ts @@ -136,10 +136,10 @@ export class PublicationTree implements AsyncIterable { * @returns Returns an array of events in the addressed event's hierarchy, beginning with the * root and ending with the addressed event. */ - async getHierarchy(address: string): Promise { + async getHierarchy(address: string): Promise { let node = this.#nodes.get(address); if (!node) { - return null; + throw new Error(`PublicationTree: Node with address ${address} not found.`); } const hierarchy: NDKEvent[] = [this.#events.get(address)!];