summaryrefslogtreecommitdiff
path: root/dhall/src/error
diff options
context:
space:
mode:
authorNadrieril2020-02-02 17:22:27 +0000
committerNadrieril2020-02-02 17:22:27 +0000
commitd8c3ced0f1acb1924c801fadbfd3077dede9b0dd (patch)
tree1884b1c33faf2c104c6b71ea8a6fd2472826da48 /dhall/src/error
parent92bbea48f9a0380a614f2687c73d55a67ff9294e (diff)
More errors
Diffstat (limited to 'dhall/src/error')
-rw-r--r--dhall/src/error/builder.rs40
1 files changed, 23 insertions, 17 deletions
diff --git a/dhall/src/error/builder.rs b/dhall/src/error/builder.rs
index 22b0d77..29d0d35 100644
--- a/dhall/src/error/builder.rs
+++ b/dhall/src/error/builder.rs
@@ -70,10 +70,11 @@ impl ErrorBuilder {
builder
}
- pub fn span_err(
+ pub fn span_annot(
&mut self,
span: &Span,
message: impl ToString,
+ annotation_type: AnnotationType,
) -> &mut Self {
// Ignore spans not coming from a source file
let span = match span {
@@ -83,33 +84,38 @@ impl ErrorBuilder {
self.annotations.push(SpannedAnnotation {
span: span.clone(),
message: message.to_string(),
- annotation_type: AnnotationType::Error,
+ annotation_type,
});
self
}
- pub fn span_help(
+ pub fn footer_annot(
&mut self,
- span: &Span,
message: impl ToString,
+ annotation_type: AnnotationType,
) -> &mut Self {
- // Ignore spans not coming from a source file
- let span = match span {
- Span::Parsed(span) => span,
- _ => return self,
- };
- self.annotations.push(SpannedAnnotation {
- span: span.clone(),
+ self.footer.push(FreeAnnotation {
message: message.to_string(),
- annotation_type: AnnotationType::Help,
+ annotation_type,
});
self
}
+
+ pub fn span_err(
+ &mut self,
+ span: &Span,
+ message: impl ToString,
+ ) -> &mut Self {
+ self.span_annot(span, message, AnnotationType::Error)
+ }
+ pub fn span_help(
+ &mut self,
+ span: &Span,
+ message: impl ToString,
+ ) -> &mut Self {
+ self.span_annot(span, message, AnnotationType::Help)
+ }
pub fn help(&mut self, message: impl ToString) -> &mut Self {
- self.footer.push(FreeAnnotation {
- message: message.to_string(),
- annotation_type: AnnotationType::Help,
- });
- self
+ self.footer_annot(message, AnnotationType::Help)
}
// TODO: handle multiple files