Rename DMError::set_cause to with_cause

This commit is contained in:
Tad Hardesty 2020-01-12 13:28:13 -08:00
parent 289928a1b6
commit 240370c8b7
5 changed files with 5 additions and 5 deletions

View file

@ -411,7 +411,7 @@ impl DMError {
}
}
pub fn set_cause<E: error::Error + Send + Sync + 'static>(mut self, cause: E) -> DMError {
pub fn with_cause<E: error::Error + Send + Sync + 'static>(mut self, cause: E) -> DMError {
self.cause = Some(Box::new(cause));
self
}

View file

@ -535,7 +535,7 @@ impl<I: Iterator<Item=io::Result<u8>>> Iterator for LocationTracker<I> {
}
Some(Ok(ch))
}
Some(Err(e)) => Some(Err(DMError::new(self.location, "i/o error").set_cause(e))),
Some(Err(e)) => Some(Err(DMError::new(self.location, "i/o error").with_cause(e))),
}
}
}

View file

@ -474,7 +474,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
}
Err(err) => self
.error(format!("i/o error, expected one of: {}", expected))
.set_cause(err),
.with_cause(err),
}
}

View file

@ -616,7 +616,7 @@ impl<'ctx> Preprocessor<'ctx> {
// Attempt to open the file.
let read = io::BufReader::new(File::open(&path).map_err(|e|
DMError::new(self.last_input_loc, format!("failed to open file: #include {:?}", path))
.set_cause(e))?);
.with_cause(e))?);
// Get the path relative to the environment root, for easy lookup later.
let register = path.strip_prefix(self.env_file.parent().unwrap()).unwrap_or(&path);

View file

@ -159,7 +159,7 @@ impl Map {
grid: Array3::default((1, 1, 1)),
};
read::parse_map(&mut map, File::open(path).map_err(|e| {
DMError::new(Location::default(), "i/o error").set_cause(e)
DMError::new(Location::default(), "i/o error").with_cause(e)
})?)?;
Ok(map)
}