Add some improvements to errors

This commit is contained in:
JT
2021-09-21 16:03:06 +12:00
parent e5aa8b9d3f
commit 4841d62d76
6 changed files with 65 additions and 26 deletions

View File

@ -574,14 +574,25 @@ impl<'a> miette::SourceCode for &StateWorkingSet<'a> {
let content_span = span_contents.span();
// Back to "global" indexing
let retranslated = (content_span.offset() + start, content_span.len()).into();
return Ok(Box::new(miette::MietteSpanContents::new_named(
filename.clone(),
span_contents.data(),
retranslated,
span_contents.line(),
span_contents.column(),
span_contents.line_count(),
)));
if filename == "<cli>" {
return Ok(Box::new(miette::MietteSpanContents::new(
span_contents.data(),
retranslated,
span_contents.line(),
span_contents.column(),
span_contents.line_count(),
)));
} else {
return Ok(Box::new(miette::MietteSpanContents::new_named(
filename.clone(),
span_contents.data(),
retranslated,
span_contents.line(),
span_contents.column(),
span_contents.line_count(),
)));
}
}
}
Err(miette::MietteError::OutOfBounds)