Exceptions: Refactoring exception making code
This commit is contained in:
parent
adf612effd
commit
43ac1b6e04
26
src/fsh.nim
26
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
|
||||
|
|
Loading…
Reference in New Issue