Skip to content

Commit

Permalink
fix: wrap error in Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Jan 18, 2024
1 parent 95c30f8 commit 753ca82
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
* @returns The requested L2 blocks, without any logs attached
*/
getBlocks(start: number, limit: number): Promise<L2Block[]> {
try {
return Promise.resolve(Array.from(this.#blockStore.getBlocks(start, limit)));
} catch (err) {
// this function is sync so if any errors are thrown we need to make sure they're passed on as rejected Promises
return Promise.reject(err);
}
return Promise.resolve(Array.from(this.#blockStore.getBlocks(start, limit)));
}

/**
Expand Down Expand Up @@ -135,7 +130,11 @@ export class KVArchiverDataStore implements ArchiverDataStore {
* @returns The requested L1 to L2 message or throws if not found.
*/
getConfirmedL1ToL2Message(messageKey: Fr): Promise<L1ToL2Message> {
return Promise.resolve(this.#messageStore.getConfirmedMessage(messageKey));
try {
return Promise.resolve(this.#messageStore.getConfirmedMessage(messageKey));
} catch (err) {
return Promise.reject(err);
}
}

/**
Expand Down

0 comments on commit 753ca82

Please sign in to comment.