Open ithinkido opened 1 year ago
This is a good feature idea. However, it would work using exceptions:
try:
doc = vp.execute_throw("....", doc)
except Exception:
pass # handle error here
Can execption
differentiate between errors and info messages ?
Info message would continue to go to stdout
. Maybe we should have a separate mechanism to capture stdout
and make it programmatically available.
A more complete workaround is:
import contextlib
import io
import vpype_cli
try:
output = io.StringIO()
with contextlib.redirect_stdout(output):
vpype_cli.execute("read doesntexist.svg show", global_opt="-vv")
print("Output")
print(output.getvalue())
except Exception as e:
print("Error:")
print(type(e))
print(e)
This captures both output and catches errors.
Would it be possible to get error messages when using the
execute
command from the vpype cli ? The use case would be something like this :