Print d->m errors when there is no room

This commit is contained in:
Cadence Ember
2026-02-04 12:56:52 +13:00
parent c01e347e7b
commit aa7222c4ed
2 changed files with 14 additions and 5 deletions
+4 -2
View File
@@ -51,13 +51,15 @@ module.exports = {
* @param {import("cloudstorm").IGatewayMessage} gatewayMessage * @param {import("cloudstorm").IGatewayMessage} gatewayMessage
*/ */
async onError(client, e, gatewayMessage) { async onError(client, e, gatewayMessage) {
if (gatewayMessage.t === "TYPING_START") return
matrixEventDispatcher.printError(gatewayMessage.t, "Discord", e, gatewayMessage)
const channelID = gatewayMessage.d["channel_id"] const channelID = gatewayMessage.d["channel_id"]
if (!channelID) return if (!channelID) return
const roomID = select("channel_room", "room_id", {channel_id: channelID}).pluck().get() const roomID = select("channel_room", "room_id", {channel_id: channelID}).pluck().get()
if (!roomID) return if (!roomID) return
if (gatewayMessage.t === "TYPING_START") return
await matrixEventDispatcher.sendError(roomID, "Discord", gatewayMessage.t, e, gatewayMessage) await matrixEventDispatcher.sendError(roomID, "Discord", gatewayMessage.t, e, gatewayMessage)
}, },
+10 -3
View File
@@ -88,6 +88,12 @@ function stringifyErrorStack(err, depth = 0) {
return collapsed; return collapsed;
} }
function printError(type, source, e, payload) {
console.error(`Error while processing a ${type} ${source} event:`)
console.error(e)
console.dir(payload, {depth: null})
}
/** /**
* @param {string} roomID * @param {string} roomID
* @param {"Discord" | "Matrix"} source * @param {"Discord" | "Matrix"} source
@@ -96,9 +102,9 @@ function stringifyErrorStack(err, depth = 0) {
* @param {any} payload * @param {any} payload
*/ */
async function sendError(roomID, source, type, e, payload) { async function sendError(roomID, source, type, e, payload) {
console.error(`Error while processing a ${type} ${source} event:`) if (source === "Matrix") {
console.error(e) printError(type, source, e, payload)
console.dir(payload, {depth: null}) }
if (Date.now() - lastReportedEvent < 5000) return null if (Date.now() - lastReportedEvent < 5000) return null
lastReportedEvent = Date.now() lastReportedEvent = Date.now()
@@ -457,3 +463,4 @@ async event => {
module.exports.stringifyErrorStack = stringifyErrorStack module.exports.stringifyErrorStack = stringifyErrorStack
module.exports.sendError = sendError module.exports.sendError = sendError
module.exports.printError = printError