feat(tvix/eval): use fancy error formatting in REPL
Change-Id: I8d5652d797b012bc3d5248ca2b2d0c87572dbf2e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6851 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com>
This commit is contained in:
parent
546f445f07
commit
d6643f66b1
3 changed files with 16 additions and 9 deletions
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
|||
use std::{fmt::Display, num::ParseIntError};
|
||||
|
||||
use codemap::{CodeMap, Span};
|
||||
use codemap_diagnostic::{Diagnostic, Emitter, Level, SpanLabel, SpanStyle};
|
||||
use codemap_diagnostic::{ColorConfig, Diagnostic, Emitter, Level, SpanLabel, SpanStyle};
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::Value;
|
||||
|
|
@ -141,6 +141,12 @@ impl Error {
|
|||
String::from_utf8_lossy(&out).to_string()
|
||||
}
|
||||
|
||||
/// Render a fancy, human-readable output of this error and print
|
||||
/// it to stderr.
|
||||
pub fn fancy_format_stderr(&self, codemap: &CodeMap) {
|
||||
Emitter::stderr(ColorConfig::Auto, Some(codemap)).emit(&[self.diagnostic(codemap)]);
|
||||
}
|
||||
|
||||
/// Create the optional span label displayed as an annotation on
|
||||
/// the underlined span of the error.
|
||||
fn span_label(&self) -> Option<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue