summaryrefslogtreecommitdiff
path: root/src/diag.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-31 22:59:14 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-01 00:00:36 +0200
commit3c92bad9a7cd6b880de197806443ffcce2cac9d8 (patch)
tree1faf79c66e23bc37711af16ad690a9878e28d348 /src/diag.rs
parentfbd3d191137aac8188ab8c6503d257d65d873972 (diff)
Pretty-printed diagnostics with traceback
Diffstat (limited to 'src/diag.rs')
-rw-r--r--src/diag.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/diag.rs b/src/diag.rs
index 76d7c6b7..397a833f 100644
--- a/src/diag.rs
+++ b/src/diag.rs
@@ -16,10 +16,21 @@ pub type StrResult<T> = Result<T, String>;
pub struct Error {
/// The file that contains the error.
pub file: FileId,
- /// The erronous location in the source code.
+ /// The erroneous location in the source code.
pub span: Span,
/// A diagnostic message describing the problem.
pub message: String,
+ /// The trace of function calls leading to the error.
+ pub trace: Vec<(FileId, Span, Tracepoint)>,
+}
+
+/// A part of an error's [trace](Error::trace).
+#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
+pub enum Tracepoint {
+ /// A function call.
+ Call(Option<String>),
+ /// A module import.
+ Import,
}
impl Error {
@@ -28,6 +39,7 @@ impl Error {
Self {
file,
span: span.into(),
+ trace: vec![],
message: message.into(),
}
}