Fixed error reporting in REPL
This commit is contained in:
parent
21738b9382
commit
15ec8dce54
|
@ -42,10 +42,13 @@ proc print*(exc: CompileError) =
|
||||||
## Prints a formatted error message
|
## Prints a formatted error message
|
||||||
## for compilation errors to stderr
|
## for compilation errors to stderr
|
||||||
var file = exc.file
|
var file = exc.file
|
||||||
if file notin ["<string>", ""]:
|
var contents: string
|
||||||
|
if file notin ["<string>", "", "stdin"]:
|
||||||
file = relativePath(exc.file, getCurrentDir())
|
file = relativePath(exc.file, getCurrentDir())
|
||||||
printError(file, readFile(file).splitLines()[exc.line - 1].strip(chars={'\n'}),
|
contents = readFile(file).splitLines()[exc.line - 1].strip(chars={'\n'})
|
||||||
exc.line, exc.node.getRelativeBoundaries(), exc.function,
|
else:
|
||||||
|
contents = ""
|
||||||
|
printError(file, contents, exc.line, exc.node.getRelativeBoundaries(), exc.function,
|
||||||
exc.msg)
|
exc.msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue