Print d->m errors when there is no room
This commit is contained in:
@@ -51,13 +51,15 @@ module.exports = {
|
||||
* @param {import("cloudstorm").IGatewayMessage} 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"]
|
||||
if (!channelID) return
|
||||
const roomID = select("channel_room", "room_id", {channel_id: channelID}).pluck().get()
|
||||
if (!roomID) return
|
||||
|
||||
if (gatewayMessage.t === "TYPING_START") return
|
||||
|
||||
await matrixEventDispatcher.sendError(roomID, "Discord", gatewayMessage.t, e, gatewayMessage)
|
||||
},
|
||||
|
||||
|
||||
@@ -88,6 +88,12 @@ function stringifyErrorStack(err, depth = 0) {
|
||||
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 {"Discord" | "Matrix"} source
|
||||
@@ -96,9 +102,9 @@ function stringifyErrorStack(err, depth = 0) {
|
||||
* @param {any} payload
|
||||
*/
|
||||
async function sendError(roomID, source, type, e, payload) {
|
||||
console.error(`Error while processing a ${type} ${source} event:`)
|
||||
console.error(e)
|
||||
console.dir(payload, {depth: null})
|
||||
if (source === "Matrix") {
|
||||
printError(type, source, e, payload)
|
||||
}
|
||||
|
||||
if (Date.now() - lastReportedEvent < 5000) return null
|
||||
lastReportedEvent = Date.now()
|
||||
@@ -457,3 +463,4 @@ async event => {
|
||||
|
||||
module.exports.stringifyErrorStack = stringifyErrorStack
|
||||
module.exports.sendError = sendError
|
||||
module.exports.printError = printError
|
||||
|
||||
Reference in New Issue
Block a user