| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-09-02 15:42:27 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-09-02 15:42:27 UTC |
| parent | f7e12b2078a261c87294f09960ab6c308201abfa |
| borogove/Client.hx | +1 | -0 |
| borogove/Util.hx | +11 | -0 |
diff --git a/borogove/Client.hx b/borogove/Client.hx index e25a22a..b8b14e2 100644 --- a/borogove/Client.hx +++ b/borogove/Client.hx @@ -1757,6 +1757,7 @@ class Client extends EventEmitter { updateChatTimer.stop(); } for (chat in data) { + assert(getChat(chat.chatId) != null, "chats/update was triggered for a chat not in chats"); updateChatBuffer[chat.chatId] = true; } if (lastCall < 0 || now - lastCall >= 500) { diff --git a/borogove/Util.hx b/borogove/Util.hx index 66e8ccb..8c92643 100644 --- a/borogove/Util.hx +++ b/borogove/Util.hx @@ -105,6 +105,17 @@ function downcast<T, S>(value: T, c: Class<S>): Null<S> { return cast Std.downcast(cast value, cast c); } +inline function assert(cond: Bool, s: String) { + if (!cond) { + #if cpp + trace(s); + untyped __cpp__("__builtin_trap()"); + #else + throw s; + #end + } +} + function xmlEscape(s: String) { // NOTE: using StringTools.htmlEscape breaks things if this is one half of a surrogate pair in an adjacent cdata return StringTools.replace(StringTools.replace(StringTools.replace(s, "&", "&"), "<", "<"), ">", ">");