diff --git a/src/matrix/kstate.js b/src/matrix/kstate.js index c901ce1..66e147a 100644 --- a/src/matrix/kstate.js +++ b/src/matrix/kstate.js @@ -12,6 +12,8 @@ const file = sync.require("./file") const api = sync.require("./api") /** @type {import("./utils")} */ const utils = sync.require("./utils") +/** @type {import("./utils")} */ +const mreq = sync.require("./mreq") /** Mutates the input. Not recursive - can only include or exclude entire state events. */ function kstateStripConditionals(kstate) { @@ -149,8 +151,16 @@ async function roomToKState(roomID, limitToEvents) { } else { const root = [] await Promise.all(limitToEvents.map(async ([type, key]) => { - const outer = await api.getStateEventOuter(roomID, type, key) - root.push(outer) + try { + const outer = await api.getStateEventOuter(roomID, type, key) + root.push(outer) + } catch (e) { + if (e instanceof mreq.MatrixServerError) { + console.warn(`Unable to fetch all events ¯\\_(ツ)_/¯\nCaught exception: ${e}`) + } else { + throw e + } + } })) return stateToKState(root) }