I wrapped the procedure in a template
template safeRunning(action : untyped) =
try:
action
except Exception as e:
error(e.msg)
then i called it here
safeRunning:
bot()
error(e.msg) crashes the program.
If you didn't what to exit, you can just echo e.msg