Exceptions: Refactoring exception making code

This commit is contained in:
Sekulum Forka 2021-05-13 15:26:14 +02:00
parent adf612effd
commit 43ac1b6e04
1 changed files with 25 additions and 1 deletions

View File

@ -31,11 +31,35 @@ type
line: int
col: int
whileExec: string
ShellVariableError=object of ShellError
ShellVariableError= object of ShellError
variable: string
ShellCommandError = object of ShellError
command: string
# procs for making procedures
proc newShellException(msg: string, line=0, col=0, whileExec=""): ref ShellError =
var e = newException(ShellError, msg)
e.line=line
e.col=col
e.whileExec = whileExec
return e
proc newShellVariableException(msg: string, vari: string, line=0, col=0, whileExec=""): ref ShellVariableError =
var e= newException(ShellVariableError, msg)
e.variable =vari
e.line=line
e.col=col
e.whileExec=whileExec
return e
proc newShellCommandException(msg: string, command: string, line=0, col=0, whileExec=""): ref ShellCommandError =
var e=newException(ShellCommandError, msg)
e.command=command
e.line=line
e.col=col
e.whileExec=whileExec
return e
# forward declarations
proc eval(cmd: string): string
proc substitute(strm: Stream, delim = ";\p"): string