cake
cake copied to clipboard
Tool.Run should make stdout and stderr available on failure
Tool.Run and related should make stdout and stderr available so that some analysis is possible on failure. Currently it calls ProcessExitCode which throws a simple CakeException.
Ideally, it would capture stdout and stderr and throw a CakeProcessException, or similar, that has additional properties for exit code, stdout and stderr.
Easiest initially would be to expose RedirectedStandardOutputHandler and RedirectedStandardErrorHandler on ToolSettings, which was just recently added to ProcessSettings in pr #2447
That would allow user to optin to do some analysis on any tool.
Redirecting all output could have major side effects as some tool aliases use the output in various ways. But adding an CakeToolException that inherits from current one but adds exit code would be a low risk great reward addition.
It shouldn’t swallow all output, I mean intercept and pass-through all output, so downstream consumers are not affected, but the intercepted output can be attached when something goes wrong.
Regardless exposing RedirectedStandardOutputHandler and RedirectedStandardErrorHandler on ToolSettings should be done, I'll raise a separate issue about that.
Attaching ExitCode, StdErr & StdOut to "cake tool exception" would be very useful, ExitCode would be totally safe, but proxying stderr & stdout could cause issues and should be opt-in in initially, it should be a cake config setting, which would make it easy to opt-in globally and potentially make it default in future.