-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
By default, print out debug information when error was encountered #282
Comments
Hey @krzkaczor, hope you're doing well! I think this is? The stack trace right now is not helpful due to a v8 bug. |
Hey David, long time no talk ;) Yeah it's definitely related to those tickets, I decided to create another ticket because I think this behaviour should be a default. Feel free to close this if you think the other tickets are enough. |
I came up with the following to work around this. It works decently well, although you lose out on the Usage: const result = await exec($`some-command`);
const json = result.stdoutJson; Implementation: export async function exec(
commandBuilder: CommandBuilder,
captureOutput = true,
): Promise<CommandResult> {
if (captureOutput) {
commandBuilder = commandBuilder
.noThrow()
.quiet()
.captureCombined();
}
const output = await commandBuilder.spawn();
if (output.code !== 0) {
const outputText = captureOutput
? output.combined
.split('\n')
.map((l) => `${' '.repeat(4)}${l}`)
.join('\n')
: '';
throw new Error(`Failed to execute command\n${outputText}`);
}
return output;
} |
@dsherret Any advice on how to move forward with building something into |
It would slow everything down and make it act differently. I think we need something like denoland/deno#7586 |
@dsherret - I can't say I fully understand the scope of the problem here. I presume denoland/deno#7586 has to do with supporting pipes ala Did some further experimenting and it seems using async function captureAsyncStackTrace<T>(fn: () => Promise<T>) {
try {
return await fn()
} catch (error) {
Error.captureStackTrace(error as Error);
throw error;
}
}
async function main() {
await captureAsyncStackTrace(() => $`cmd-does-not-exist`.text());
}
await main(); I'm wondering if we could incorporate the |
Simple code such:
Throws totally unhelpful error message like
(often even stack trace is not helpful).
I think the default behaviour should be to throw an error with command name that was executed and at least few final lines of stderr and stdout.
For reference, this is what bun/shell will do (output and error code both parts of the responses):
![image](https://private-user-images.githubusercontent.com/1814312/357381479-9fbfc427-52c6-478d-9d49-b72b460d48a8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NTQ0MDUsIm5iZiI6MTczOTQ1NDEwNSwicGF0aCI6Ii8xODE0MzEyLzM1NzM4MTQ3OS05ZmJmYzQyNy01MmM2LTQ3OGQtOWQ0OS1iNzJiNDYwZDQ4YTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMTM0MTQ1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTk2NjhjNmRmMDcxYTg3YTJiOTlhOTlmOTZmNzUxMzM2YzQ2MTBjYjI0OThmZmEzZjFkZmRjMTBlMTc3NGVlNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.19Soaq-DJwBGfBWjFANxzPpSmk6NuA9qOki_E6fYEu8)
The text was updated successfully, but these errors were encountered: