Better error when missing file

This commit is contained in:
Thomas Forgione 2018-11-13 15:49:30 +01:00
parent 0aaac28d81
commit e040ef14ff
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
2 changed files with 6 additions and 2 deletions

View File

@ -71,7 +71,7 @@ impl LineParser for MtlParser {
full_path.push(split[4].to_owned());
Ok(Element::Texture(first.to_owned(), full_path.to_str().unwrap().to_owned(), size))
} else {
Err(ParserError::UnexpectedKeyword(path.to_owned(), line_number, split[2].to_owned()))
Err(ParserError::UnexpectedKeyword(path.to_owned(), line_number, split[1].to_owned()))
}
},

View File

@ -136,7 +136,11 @@ impl Renderer {
/// Creates a SrgbTexture from a path to an image.
pub fn make_texture(&self, path: &str) -> SrgbTexture2d {
let image = image::open(path).unwrap().to_rgba();
let image = match image::open(path) {
Ok(r) => r.to_rgba(),
Err(e) => panic!("Error while opening file {}: {}", path, e),
};
self.make_texture_from_buffer(image)
}