mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(diagnostics): ignore Interrupted and BrokenPipe errors while printing (#5526)
closes #5452
This commit is contained in:
parent
7a797ac635
commit
fce549e648
1 changed files with 23 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::io::{BufWriter, Stdout, Write};
|
||||
use std::io::{BufWriter, ErrorKind, Stdout, Write};
|
||||
|
||||
use super::{writer, DiagnosticReporter};
|
||||
use crate::{Error, GraphicalReportHandler};
|
||||
|
|
@ -16,11 +16,31 @@ impl Default for GraphicalReporter {
|
|||
|
||||
impl DiagnosticReporter for GraphicalReporter {
|
||||
fn finish(&mut self) {
|
||||
self.writer.flush().unwrap();
|
||||
self.writer
|
||||
.flush()
|
||||
.or_else(|e| {
|
||||
// Do not panic when the process is skill (e.g. piping into `less`).
|
||||
if matches!(e.kind(), ErrorKind::Interrupted | ErrorKind::BrokenPipe) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn render_diagnostics(&mut self, s: &[u8]) {
|
||||
self.writer.write_all(s).unwrap();
|
||||
self.writer
|
||||
.write_all(s)
|
||||
.or_else(|e| {
|
||||
// Do not panic when the process is skill (e.g. piping into `less`).
|
||||
if matches!(e.kind(), ErrorKind::Interrupted | ErrorKind::BrokenPipe) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn render_error(&mut self, error: Error) -> Option<String> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue