Better error when missing file
This commit is contained in:
		
							parent
							
								
									0aaac28d81
								
							
						
					
					
						commit
						e040ef14ff
					
				@ -71,7 +71,7 @@ impl LineParser for MtlParser {
 | 
				
			|||||||
                        full_path.push(split[4].to_owned());
 | 
					                        full_path.push(split[4].to_owned());
 | 
				
			||||||
                        Ok(Element::Texture(first.to_owned(), full_path.to_str().unwrap().to_owned(), size))
 | 
					                        Ok(Element::Texture(first.to_owned(), full_path.to_str().unwrap().to_owned(), size))
 | 
				
			||||||
                    } else {
 | 
					                    } 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()))
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
				
			|||||||
@ -136,7 +136,11 @@ impl Renderer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /// Creates a SrgbTexture from a path to an image.
 | 
					    /// Creates a SrgbTexture from a path to an image.
 | 
				
			||||||
    pub fn make_texture(&self, path: &str) -> SrgbTexture2d {
 | 
					    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)
 | 
					        self.make_texture_from_buffer(image)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user