Skip to content

Instantly share code, notes, and snippets.

@Yardanico
Created July 26, 2017 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yardanico/40d2e55c8c9d2f1c4c2986b8f3fc53b6 to your computer and use it in GitHub Desktop.
Save Yardanico/40d2e55c8c9d2f1c4c2986b8f3fc53b6 to your computer and use it in GitHub Desktop.
type ModuleFunction = proc(api: VkApi, msg: Message): Future[void]
proc runCatch*(exec: ModuleFunction, bot: VkBot, msg: Message) =
let future = exec(bot.api, msg)
future.callback =
proc () =
if not future.failed:
return
try:
raise future.error
except:
let rnd = antiFlood() & "\n"
var errorMessage = rnd & bot.config.errorMessage & "\n"
if bot.config.fullReport:
errorMessage &= "\n" & getCurrentExceptionMsg()
if bot.config.logErrors:
error("\n" & getCurrentExceptionMsg())
if bot.config.reportErrors:
asyncCheck bot.api.answer(msg, errorMessage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment