dgtools - argvparse - recover - repo - shistory
dgtools::recover - debugging command
package require dgtools::recover
dgtools::recover
dgtools::recover_onerror
dgtools::recover_stop
The dgtools::recover command allows to debug interactively errors pr problems in Tcl terminal programs in the same spirit as the R recover command.
dgtools::recover
Manually jumps in debugging mode. This command can be placed into critical code fragments and then you can jump directly during debugging in this procedure. See the following example:
proc test {x} { set y $x incr y dgtools::recover incr x return $y } test 5
dgtools::recover_onerror
This replaces the error command, instead of reporting the error there will be an interactive terminal where you can debug all variables in the current procedure or method.
dgtools::recover_stop
This resets the error handling by the recover command to the normal error command.
The following example shows how you can jump into your own error calls in your code. As you normally report critical parts of your code with such error calls it allows you to jump directly into those places and debug them. Unfortunately, I don't know how to jump automatically into the error call of Tcl.
package require dgtools::recover
::dgtools::recover_onerror
proc test {x} {
set y $x
# the next line with the error
# will jump into the recover moce
error "z does not exists"
return $z
}
test 6
The script contains embedded the documentation in Markdown format. To extract the documentation you should use the following command line:
$ tclsh recover.tcl --man
The output of this command can be used to create a markdown document for conversion into a markdown document that can be converted thereafter into a html or pdf document. If, for instance, you have pandoc installed you could execute the following commands:
tclsh recover.tcl --man > recover.md
pandoc -i recover.md -s -o recover.html
pandoc -i recover.md -s -o recover.tex
pdflatex recover.tex
Alternatively if the Markdown package of tcllib is available you can convert the documentation as well directly to html using the --html flag:
$ tclsh recover.tcl --html
The dgtools::recover command was written Detlef Groth, Schwielowsee, Germany.
Copyright (c) 2020 Dr. Detlef Groth, E-mail: detlef(at)dgroth(dot)de
dgtools:recover package - debugging tool in spirit of R's recover function.
Copyright (c) 2020 Dr. Detlef Groth, E-mail: detlef(at)dgroth(dot)de
This library is free software; you can use, modify, and redistribute it for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions.
This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.