mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 21:44:34 +00:00
Add helpers for manipulating errors
This commit is contained in:
parent
3013d708d8
commit
747974d37c
2 changed files with 29 additions and 0 deletions
|
@ -642,6 +642,19 @@ impl ErrorCore {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_loc_with_fallback(&self) -> Location {
|
||||
if self.loc == Location::Unknown {
|
||||
for sub in &self.sub_messages {
|
||||
if sub.loc != Location::Unknown {
|
||||
return sub.loc;
|
||||
}
|
||||
}
|
||||
Location::Unknown
|
||||
} else {
|
||||
self.loc
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fmt_header(&self, color: Color, caused_by: &str, input: &str) -> String {
|
||||
let loc = match self.loc {
|
||||
Location::Range {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue