From 1dcd5620c43a6bd1767aa4eae6c55f8abb4ca813 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Mon, 17 Aug 2026 17:30:06 +1200 Subject: [PATCH] SnowTransfer error handling is no longer pathetic --- src/d2m/actions/update-pins.js | 2 +- src/d2m/converters/message-to-event.js | 2 +- src/d2m/event-dispatcher.js | 2 +- src/db/migrations/0037-remove-leaked-webhooks.js | 2 +- src/m2d/actions/channel-webhook.js | 2 +- src/matrix/matrix-command-handler.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d2m/actions/update-pins.js b/src/d2m/actions/update-pins.js index 56c9642..0ecbed0 100644 --- a/src/d2m/actions/update-pins.js +++ b/src/d2m/actions/update-pins.js @@ -28,7 +28,7 @@ async function updatePins(channelID, roomID, convertedTimestamp) { try { var discordPins = await discord.snow.channel.getChannelPinnedMessages(channelID) } catch (e) { - if (e.message === `{"message": "Missing Access", "code": 50001}`) { + if (e.message === "Missing Access") { return // Discord sends channel pins update events even for channels that the bot can't view/get pins in, just ignore it } throw e diff --git a/src/d2m/converters/message-to-event.js b/src/d2m/converters/message-to-event.js index 79c0298..1f055e3 100644 --- a/src/d2m/converters/message-to-event.js +++ b/src/d2m/converters/message-to-event.js @@ -834,7 +834,7 @@ async function messageToEvent(message, guild, options = {}, di) { invite = await di.snow.invite.getInvite(match[1], {guild_scheduled_event_id: match[2]}) } catch (e) { // Skip expired/invalid invites and events - if (e.message === `{"message": "Unknown Invite", "code": 10006}`) { + if (e.message === "Unknown Invite") { break } else { throw e diff --git a/src/d2m/event-dispatcher.js b/src/d2m/event-dispatcher.js index ef74755..02cb20f 100644 --- a/src/d2m/event-dispatcher.js +++ b/src/d2m/event-dispatcher.js @@ -107,7 +107,7 @@ module.exports = { try { messages = await client.snow.channel.getChannelMessages(channel.id, {limit: 100}) } catch (e) { - if (e.message === `{"message": "Missing Access", "code": 50001}`) { // pathetic error handling from SnowTransfer + if (e.message === "Missing Access") { console.log(`[check missed messages] no permissions to look back in channel ${channel.name} (${channel.id})`) continue // Sucks. } else { diff --git a/src/db/migrations/0037-remove-leaked-webhooks.js b/src/db/migrations/0037-remove-leaked-webhooks.js index 0228053..b839bd7 100644 --- a/src/db/migrations/0037-remove-leaked-webhooks.js +++ b/src/db/migrations/0037-remove-leaked-webhooks.js @@ -27,7 +27,7 @@ module.exports = async function(db) { const webhook = affectedWebhooks[counter-1] await discord.snow.webhook.deleteWebhookToken(webhook.webhook_id, webhook.webhook_token, "Webhook token possibly compromised during 8th May 2026 outage").catch(e => { - if (e.message === `{"message": "Unknown Webhook", "code": 10015}`) { + if (e.message === "Unknown Webhook") { // OK } else { throw e diff --git a/src/m2d/actions/channel-webhook.js b/src/m2d/actions/channel-webhook.js index 09c642b..01b3dd4 100644 --- a/src/m2d/actions/channel-webhook.js +++ b/src/m2d/actions/channel-webhook.js @@ -45,7 +45,7 @@ async function ensureWebhook(channelID, forceCreate = false) { async function withWebhook(channelID, callback) { const webhook = await ensureWebhook(channelID, false) return callback(webhook).catch(async e => { - if (e.message === `{"message": "Unknown Webhook", "code": 10015}`) { // pathetic error handling from SnowTransfer + if (e.message === "Unknown Webhook") { // Our webhook is gone. Maybe somebody deleted it, or removed and re-added OOYE from the guild. const newWebhook = await ensureWebhook(channelID, true) return callback(newWebhook) // not caught; if the error happens again just throw it instead of looping diff --git a/src/matrix/matrix-command-handler.js b/src/matrix/matrix-command-handler.js index b38b4b1..aa80b9c 100644 --- a/src/matrix/matrix-command-handler.js +++ b/src/matrix/matrix-command-handler.js @@ -296,7 +296,7 @@ const commands = [{ try { var invite = await discord.snow.channel.createChannelInvite(channelID) } catch (e) { - if (e.message === `{"message": "Missing Permissions", "code": 50013}`) { + if (e.message === "Missing Permissions") { return api.sendEvent(event.room_id, "m.room.message", { ...ctx, msgtype: "m.text",