nim-eth/eth/async_utils.nim

21 lines
504 B
Nim
Raw Normal View History

import
2019-09-10 21:28:38 +00:00
chronos, chronicles
2019-04-05 08:13:22 +00:00
proc catchOrQuit(error: Exception) =
if error of CatchableError:
trace "Async operation ended with a recoverable error", err = error.msg
else:
fatal "Fatal exception reached", err = error.msg
quit 1
proc traceAsyncErrors*(fut: FutureBase) =
fut.addCallback do (arg: pointer):
if not fut.error.isNil:
2019-04-05 08:13:22 +00:00
catchOrQuit fut.error[]
2019-04-05 08:13:22 +00:00
template traceAwaitErrors*(fut: FutureBase) =
let f = fut
yield f
if not f.error.isNil:
catchOrQuit f.error[]