From 753ca825a479e76a43001e487ab153020df435a5 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 18 Jan 2024 11:39:51 +0000 Subject: [PATCH] fix: wrap error in Promise --- .../archiver/kv_archiver_store/kv_archiver_store.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts index 5c914b8193c3..439b06c6cfde 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts @@ -57,12 +57,7 @@ export class KVArchiverDataStore implements ArchiverDataStore { * @returns The requested L2 blocks, without any logs attached */ getBlocks(start: number, limit: number): Promise { - 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))); } /** @@ -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 { - return Promise.resolve(this.#messageStore.getConfirmedMessage(messageKey)); + try { + return Promise.resolve(this.#messageStore.getConfirmedMessage(messageKey)); + } catch (err) { + return Promise.reject(err); + } } /**