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
|
line: int
|
||||||
col: int
|
col: int
|
||||||
whileExec: string
|
whileExec: string
|
||||||
ShellVariableError=object of ShellError
|
ShellVariableError= object of ShellError
|
||||||
variable: string
|
variable: string
|
||||||
ShellCommandError = object of ShellError
|
ShellCommandError = object of ShellError
|
||||||
command: string
|
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
|
# forward declarations
|
||||||
proc eval(cmd: string): string
|
proc eval(cmd: string): string
|
||||||
proc substitute(strm: Stream, delim = ";\p"): string
|
proc substitute(strm: Stream, delim = ";\p"): string
|
||||||
|
|
Loading…
Reference in New Issue