summaryrefslogtreecommitdiff
path: root/src/errors/merge_error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors/merge_error.rs')
-rw-r--r--src/errors/merge_error.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/errors/merge_error.rs b/src/errors/merge_error.rs
index 89f55a2..01cbcba 100644
--- a/src/errors/merge_error.rs
+++ b/src/errors/merge_error.rs
@@ -1,8 +1,5 @@
use crate::*;
-use ansi::*;
-use log::error;
-
use std::collections::HashSet;
@@ -14,15 +11,19 @@ pub struct MergeError<'a> {
impl MergeError<'_> {
pub fn report(&self) {
- error!("A cyclic dependency was found between the following files:");
+ let message = "A cyclic dependency was found between the following files:";
+ let mut details = InkedString::new();
for id in &self.cyclic_unit_ids {
let unit = &self.resolver.source_units[*id];
let path = &unit.source_unit.path();
match unit.source_unit.name() {
- Some(name) =>
- eprintln!("{name}{NORMAL}{DIM} ({path}){NORMAL}"),
- None =>
- eprintln!("{path}"),
+ Some(name) => {
+ details.push(ink!("{name}"));
+ details.push(ink!(" ({path})\n").dim());
+ }
+ None => {
+ details.push(ink!("{path}\n"));
+ }
};
// Print each parent involved in the dependency cycle.
for parent_id in &unit.parent_ids {
@@ -30,10 +31,13 @@ impl MergeError<'_> {
let parent_unit = &self.resolver.source_units[*parent_id];
let parent_path = &parent_unit.source_unit.path();
match parent_unit.source_unit.name() {
- Some(parent_name) =>
- eprintln!(" => {parent_name} {DIM}({parent_path}){NORMAL}"),
- None =>
- eprintln!(" => {parent_path}"),
+ Some(parent_name) => {
+ details.push(ink!(" => {parent_name}"));
+ details.push(ink!(" ({parent_path})\n").dim());
+ }
+ None => {
+ details.push(ink!(" => {parent_path}\n"));
+ }
};
// Report all referenced symbols that are defined by this parent.
let mut reported_definition_ids = HashSet::new();
@@ -42,12 +46,13 @@ impl MergeError<'_> {
if reported_definition_ids.insert(reference.definition) {
let definition = &self.resolver.definitions[reference.definition];
if definition.tracked.source_id == *parent_id {
- eprintln!(" {:?}", definition.tracked.symbol);
+ details.push(ink!(" {:?}\n", definition.tracked.symbol));
}
}
}
}
}
}
+ log_error(message, Some(details));
}
}