Browse Source

Throw error rather than return `null`

master
buttercat1791 1 year ago
parent
commit
e8ed3ac08f
  1. 4
      src/lib/data_structures/publication_tree.ts

4
src/lib/data_structures/publication_tree.ts

@ -136,10 +136,10 @@ export class PublicationTree implements AsyncIterable<NDKEvent> { @@ -136,10 +136,10 @@ export class PublicationTree implements AsyncIterable<NDKEvent> {
* @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<NDKEvent[] | null> {
async getHierarchy(address: string): Promise<NDKEvent[]> {
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)!];

Loading…
Cancel
Save