From 4fae0eb1003a45436d19267e5528b95e0ad6557c Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 16 Jul 2020 11:40:39 -0400 Subject: [PATCH] fix: capture RpcExceptions generated by stickers that would not allow login --- src/status/chat.nim | 39 ++++++++++++++++++++----------- src/status/libstatus/stickers.nim | 24 +++++++++---------- src/status/libstatus/types.nim | 6 ++++- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/status/chat.nim b/src/status/chat.nim index 934fd5e1aa..67a1027155 100644 --- a/src/status/chat.nim +++ b/src/status/chat.nim @@ -9,6 +9,9 @@ import ../signals/types as signal_types import ens import eth/common/eth_types +logScope: + topics = "chat-model" + type ChatUpdateArgs* = ref object of Args chats*: seq[Chat] @@ -99,12 +102,16 @@ proc getPurchasedStickerPacks*(self: ChatModel, address: EthAddress): seq[int] = if self.purchasedStickerPacks != @[]: return self.purchasedStickerPacks - var balance = status_stickers.getBalance(address) - # balance = 2 # hardcode to test support of purchased sticker packs, because buying sticker packs is proving very difficult on testnet - var tokenIds = toSeq[0.. status_stickers.tokenOfOwnerByIndex(address, idx)) - # tokenIds = @[1, 2] # hardcode to test support of purchased sticker packs - self.purchasedStickerPacks = tokenIds.map(tokenId => status_stickers.getPackIdFromTokenId(tokenId)) - result = self.purchasedStickerPacks + try: + var balance = status_stickers.getBalance(address) + # balance = 2 # hardcode to test support of purchased sticker packs, because buying sticker packs is proving very difficult on testnet + var tokenIds = toSeq[0.. status_stickers.tokenOfOwnerByIndex(address, idx)) + # tokenIds = @[1, 2] # hardcode to test support of purchased sticker packs + self.purchasedStickerPacks = tokenIds.map(tokenId => status_stickers.getPackIdFromTokenId(tokenId)) + result = self.purchasedStickerPacks + except RpcException: + error "Error in getPurchasedStickerPacks", message = getCurrentExceptionMsg() + result = @[] proc getInstalledStickerPacks*(self: ChatModel): Table[int, StickerPack] = if self.installedStickerPacks != initTable[int, StickerPack](): @@ -117,14 +124,18 @@ proc getAvailableStickerPacks*(self: ChatModel): Table[int, StickerPack] = if self.availableStickerPacks != initTable[int, StickerPack](): return self.availableStickerPacks - let numPacks = status_stickers.getPackCount() - for i in 0..