I want to catch certain errors from a command line tool I'm executing. What is the best way to do this? I had trouble finding examples of this in the docs.
I'm doing this:
result = None
try:
result = ctx.run(
"somecommand",
hide=False,
)
except UnexpectedExit:
print(result.stderr)
When I try to print result.stderr it throws an actual error.
How do I search the stderr output a command returns for a substring and raise my own exception or log message if the substring exists in the error output?
I also tried using warn=true, but if I do that how do I check if an error was returned and if so see if it contains my substring?
I want to catch certain errors from a command line tool I'm executing. What is the best way to do this? I had trouble finding examples of this in the docs.
I'm doing this:
When I try to print
result.stderr
it throws an actual error.How do I search the stderr output a command returns for a substring and raise my own exception or log message if the substring exists in the error output?
I also tried using warn=true, but if I do that how do I check if an error was returned and if so see if it contains my substring?