Exceptions: Add an exception for ^c

This commit is contained in:
Sekulum Forka 2021-05-13 22:05:15 +02:00
parent 5116918ff2
commit 87982fdcbc
1 changed files with 8 additions and 1 deletions

View File

@ -35,6 +35,7 @@ type
variable: string
ShellCommandError = object of ShellError
command: string
InterruptCtrlC = object of CatchableError
# procs for making procedures
proc newShellException(msg: string, line=0, col=0, whileExec=""): ref ShellError =
@ -323,4 +324,10 @@ proc eval(cmd: string): string =
when isMainModule:
let stdinstrm = stdin.newFileStream
while not stdinstrm.atEnd():
stdinstrm.readCommand.execute.echo
try:
discard stdinstrm.readCommand.execute
except ShellError, ShellCommandError, ShellVariableError:
let e = getCurrentException()
stderr.write(e.msg, "\n")
except InterruptCtrlC:
continue