fix(zone-exec): catch panic errors and show all errors immediately (#359)

This commit is contained in:
Alex Zenla
2024-08-25 00:16:20 -07:00
committed by GitHub
parent 96ccbd50bb
commit 0106b85de9
3 changed files with 40 additions and 34 deletions

View File

@ -1,4 +1,4 @@
use anyhow::{anyhow, Result};
use anyhow::Result;
use async_stream::stream;
use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode, is_raw_mode_enabled},
@ -118,7 +118,12 @@ impl StdioConsoleStream {
return if reply.error.is_empty() {
Ok(reply.exit_code)
} else {
Err(anyhow!("exec failed: {}", reply.error))
StdioConsoleStream::restore_terminal_mode();
stderr
.write_all(format!("Error: exec failed: {}\n", reply.error).as_bytes())
.await?;
stderr.flush().await?;
Ok(-1)
};
}
}