diff options
| author | Timothee Cour <timothee.cour2@gmail.com> | 2019-01-29 21:45:19 -0800 |
|---|---|---|
| committer | genotrance <dev@genotrance.com> | 2019-01-29 23:45:19 -0600 |
| commit | 69aaa8725362b04eebe1ae1ddf57f3c9cd4d7a6d (patch) | |
| tree | d1ccc88634b9a4f814037c0da4f7b7687e607423 | |
| parent | 839c4007f6a9e2b820be152df64f5f602535e18f (diff) | |
| download | nimterop-69aaa8725362b04eebe1ae1ddf57f3c9cd4d7a6d.tar.gz nimterop-69aaa8725362b04eebe1ae1ddf57f3c9cd4d7a6d.zip | |
`quit => doAssert` to show backtrace + relevant context + exception friendly (#85)
| -rw-r--r-- | nimterop/git.nim | 6 | ||||
| -rw-r--r-- | nimterop/lisp.nim | 9 |
2 files changed, 5 insertions, 10 deletions
diff --git a/nimterop/git.nim b/nimterop/git.nim index edd2156..2315204 100644 --- a/nimterop/git.nim +++ b/nimterop/git.nim @@ -19,10 +19,8 @@ proc execAction*(cmd: string, nostderr=false): string = else: (result, ret) = execCmdEx(ccmd) if ret != 0: - echo "Command failed: " & $ret - echo ccmd - echo result - quit(1) + let msg = "Command failed: " & $ret & "\nccmd: " & ccmd & "\nresult:\n" & result + doAssert false, msg proc extractZip*(zipfile, outdir: string) = var cmd = "unzip -o $#" diff --git a/nimterop/lisp.nim b/nimterop/lisp.nim index c21c3be..119de36 100644 --- a/nimterop/lisp.nim +++ b/nimterop/lisp.nim @@ -25,13 +25,11 @@ proc tokenize(tree: string) = proc readFromTokens(): ref Ast = if idx == gTokens.len: - echo "Bad AST" - quit(1) + doAssert false, "Bad AST " & $(idx: idx) if gTokens[idx] == "(": if gTokens.len - idx < 2: - echo "Corrupt AST" - quit(1) + doAssert false, "Corrupt AST " & $(gTokensLen: gTokens.len, idx: idx) if gTokens[idx+1] != "comment": result = new(Ast) (result.name, result.kind, result.recursive) = gTokens[idx+1].getNameKind() @@ -44,8 +42,7 @@ proc readFromTokens(): ref Ast = if not res.isNil(): result.children.add(res) elif gTokens[idx] == ")": - echo "Poor AST" - quit(1) + doAssert false, "Poor AST " & $(idx: idx) idx += 1 |
