mirror of https://github.com/status-im/nim-eth.git
Delegate traceAsyncErrors to Chronicles
This commit is contained in:
parent
67be352b91
commit
5eff071c8e
|
@ -1,23 +1,8 @@
|
||||||
import
|
import
|
||||||
chronos, chronicles
|
chronos, chronicles, chronicles/chronos_tools
|
||||||
|
|
||||||
proc catchOrQuit*(error: Exception) =
|
export
|
||||||
if error of CatchableError:
|
chronos_tools
|
||||||
trace "Async operation ended with a recoverable error", err = error.msg
|
|
||||||
else:
|
|
||||||
fatal "Fatal exception reached", err = error.msg, stackTrace = getStackTrace()
|
|
||||||
quit 1
|
|
||||||
|
|
||||||
proc traceAsyncErrors*(fut: FutureBase) =
|
|
||||||
fut.addCallback do (arg: pointer):
|
|
||||||
if not fut.error.isNil:
|
|
||||||
catchOrQuit fut.error[]
|
|
||||||
|
|
||||||
template traceAwaitErrors*(fut: FutureBase) =
|
|
||||||
let f = fut
|
|
||||||
yield f
|
|
||||||
if not f.error.isNil:
|
|
||||||
catchOrQuit f.error[]
|
|
||||||
|
|
||||||
template awaitWithTimeout*[T](operation: Future[T],
|
template awaitWithTimeout*[T](operation: Future[T],
|
||||||
deadline: Future[void],
|
deadline: Future[void],
|
||||||
|
|
Loading…
Reference in New Issue