fix(async_tasks): add try catch to getChannelGroups async task

Kind of fixes #13640

The issue itself was no reproducible even after dozens of restarts and following of the repro steps.
It seems like this was an unfortunate DB close event that caused the app to close.

Adding a try catch won't actually fix that, since the DB is closed and also the `communtiies`already had a try/catch, but it will help for later.
This commit is contained in:
Jonathan Rainville 2024-02-21 15:39:39 -05:00
parent fae86bcb8d
commit d6e13d709f
2 changed files with 14 additions and 6 deletions

View File

@ -6,13 +6,18 @@ type
const asyncGetChannelGroupsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const asyncGetChannelGroupsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[AsyncGetChannelGroupsTaskArg](argEncoded) let arg = decode[AsyncGetChannelGroupsTaskArg](argEncoded)
try:
let response = status_chat.getChannelGroups() let response = status_chat.getChannelGroups()
let responseJson = %*{ let responseJson = %*{
"channelGroups": response.result "channelGroups": response.result,
"error": "",
} }
arg.finish(responseJson) arg.finish(responseJson)
except Exception as e:
arg.finish(%* {
"error": e.msg,
})
type type
AsyncCheckChannelPermissionsTaskArg = ref object of QObjectTaskArg AsyncCheckChannelPermissionsTaskArg = ref object of QObjectTaskArg

View File

@ -240,6 +240,9 @@ QtObject:
try: try:
let rpcResponseObj = response.parseJson let rpcResponseObj = response.parseJson
if (rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != ""):
raise newException(CatchableError, rpcResponseObj{"error"}.getStr)
if(rpcResponseObj["channelGroups"].kind == JNull): if(rpcResponseObj["channelGroups"].kind == JNull):
raise newException(RpcException, "No channel groups returned") raise newException(RpcException, "No channel groups returned")