error handling - Expect Scripting - Raising Exceptions -
error handling - Expect Scripting - Raising Exceptions -
im trying larn expect scripting run backend process, there way raise , grab error exception language?
ex. python
class="lang-py prettyprint-override">try: raise exception("test") except exception, e: print e
what's equivalent in expect?
#!/usr/bin/expect bundle require expect # raise , grab exception
if you're using tcl 8.6 (which expect bundle load nicely), literal translation of python code is:
try { throw exception "test" } trap exception e { puts $e }
now, try
, throw
commands added in 8.6 create sort of thing easier. prior (all way far farther can search conveniently) instead this:
if {[catch { error "test" } e] == 1} { puts $e }
which easy plenty in case, rather more error-prone 1 time things more complex.
exception error-handling tcl expect
Comments
Post a Comment