source: fix invalid source ID printing
Don't resolve the path of `Source` if the ID is 0, i.e. it corresponds
to the `INVALID_SOURCE`. This caused the program to panick whenever an
invalid source was to be printed for debugging purposes.
@@ -47,7 +47,11 @@ impl Source {
impl fmt::Debug for Source {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ if self.0 > 0 {
write!(f, "Source({}; \"{}\")", self.0, self.get_path())
+ } else {
+ write!(f, "Source(INVALID)")
+ }
}
}
