Created
July 26, 2017 10:57
-
-
Save Yardanico/40d2e55c8c9d2f1c4c2986b8f3fc53b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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