fix: map_err()? instead of unwrap (#3826)

This commit is contained in:
Alexander Brevig 2022-09-13 08:08:23 +02:00 committed by GitHub
parent 800a490676
commit 16b9a1841f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -985,7 +985,9 @@ pub fn tree(&self) -> &Tree {
}
fn parse(&mut self, parser: &mut Parser, source: &Rope) -> Result<(), Error> {
parser.set_included_ranges(&self.ranges).unwrap();
parser
.set_included_ranges(&self.ranges)
.map_err(|_| Error::InvalidRanges)?;
parser
.set_language(self.config.language)
@ -1135,6 +1137,7 @@ fn traverse(point: Point, text: &Tendril) -> Point {
pub enum Error {
Cancelled,
InvalidLanguage,
InvalidRanges,
Unknown,
}