src/pylib/pysugar/stmt/pyraise

Search:
Group by:
Source   Edit  

Implement NOTE: We cannot define a macro or function called raise, as in Nim, raise, a keyword, will be parsed as part of nnkRaiseStmt.

Procs

proc rewriteRaise(rStmt: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
  • Rewrites raise ErrType/ErrType()/ErrType(msg) to raise newException(ErrType, msg/"")
  • Rewrites raise XxError[(...)] to raise new[Py]XxError(...)
  • Rewrites raise XxError[(...)] from P to raise new[Py]OSError(...).add_parent(P)

assume rStmt is nnkRaiseStmt

Source   Edit