diff --git a/src/fsh.nim b/src/fsh.nim index 624ed69..9b90010 100644 --- a/src/fsh.nim +++ b/src/fsh.nim @@ -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