summaryrefslogtreecommitdiff
path: root/oryxc
diff options
context:
space:
mode:
Diffstat (limited to 'oryxc')
-rw-r--r--oryxc/src/errors.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/oryxc/src/errors.rs b/oryxc/src/errors.rs
index b9b5955..b2bab4e 100644
--- a/oryxc/src/errors.rs
+++ b/oryxc/src/errors.rs
@@ -10,11 +10,13 @@ use std::fmt::{
Display,
Formatter,
};
+use std::io::Write;
use std::ops::Deref;
use std::path::Path;
use std::sync::OnceLock;
use std::{
env,
+ io,
process,
};
@@ -145,24 +147,28 @@ impl OryxError {
const ERRORBEG: &str = "\x1b[31;1m";
const FMTEND: &str = "\x1b[0m";
- eprintln!(
- "{FNAMEBEG}{}:{line}:{col}:{FMTEND} {ERRORBEG}error:{FMTEND} {self}",
+ let mut handle = io::stderr().lock();
+ let _ = write!(
+ handle,
+ "{FNAMEBEG}{}:{line}:{col}:{FMTEND} {ERRORBEG}error:{FMTEND} {self}\n",
filename.as_ref().display()
);
- eprintln!(" {line:>4} │ {errbeg}{ERRORBEG}{errmid}{FMTEND}{errend}");
+ let _ = write!(
+ handle,
+ " {line:>4} │ {errbeg}{ERRORBEG}{errmid}{FMTEND}{errend}\n"
+ );
for _ in 0..nspaces(line) {
- eprint!(" ");
+ let _ = write!(handle, " ");
}
- eprint!("│ ");
+ let _ = write!(handle, "│ ");
for _ in 1..col {
- eprint!(" ");
+ let _ = write!(handle, " ");
}
- eprint!("{ERRORBEG}");
+ let _ = write!(handle, "{ERRORBEG}");
for _ in 0..errmid.width().max(1) {
- eprint!("^");
+ let _ = write!(handle, "^");
}
- eprint!("{FMTEND}");
- eprintln!();
+ let _ = write!(handle, "{FMTEND}\n");
}
}