Implement some simple pattern-based transformation for async tracebacks.

This commit is contained in:
Dominik Picheta
2017-11-24 22:48:53 +00:00
committed by Andreas Rumpf
parent f3a895f043
commit f73015ad9e
2 changed files with 115 additions and 10 deletions

View File

@@ -0,0 +1,46 @@
discard """
exitcode: 0
output: ""
"""
import asyncdispatch
# Tests to ensure our exception trace backs are friendly.
# --- Simple test. ---
#
# What does this look like when it's synchronous?
#
# tasync_traceback.nim(23) tasync_traceback
# tasync_traceback.nim(21) a
# tasync_traceback.nim(18) b
# Error: unhandled exception: b failure [OSError]
#
# Good (not quite ideal, but gotta work within constraints) traceback,
# when exception is unhandled:
#
# <traceback for the unhandled exception>
# <very much a bunch of noise>
# <would be ideal to customise this>
# <(the code responsible is in excpt:raiseExceptionAux)>
# Error: unhandled exception: b failure
# ===============
# Async traceback
# ===============
#
# tasync_traceback.nim(23) tasync_traceback
#
# tasync_traceback.nim(21) a
# tasync_traceback.nim(18) b
proc b(): Future[int] {.async.} =
if true:
raise newException(OSError, "b failure")
proc a(): Future[int] {.async.} =
return await b()
let aFut = a()
# try:
discard waitFor aFut
# except Exception as exc:
# echo exc.msg