From 3ac1e5e5a9ebcb4beb2bfe149dd5095f2250f60d Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 20 Jul 2026 20:43:48 -0700 Subject: load a nontrivial model and render it with a texture yay Force-Push: yes Change-Id: Icb715692286c8560532ab73d32a49be8f485d790 --- src/error.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 729ff23..304ed74 100644 --- a/src/error.rs +++ b/src/error.rs @@ -115,6 +115,48 @@ impl From for Error { } } +impl From for Error { + fn from(e: tobj::LoadError) -> Self { + Error { + message: format!("While loading model from .obj: {}", + match e + { + tobj::LoadError::OpenFileFailed => "Can't open file.", + tobj::LoadError::ReadError => "Can't read from file.", + tobj::LoadError::UnrecognizedCharacter => + "Syntax error: Invalid character.", + tobj::LoadError::PositionParseError => + "Syntax error describing a spatial position.", + tobj::LoadError::NormalParseError => + "Syntax error describing a normal vector.", + tobj::LoadError::TexcoordParseError => + "Syntax error describing texture coordinates.", + tobj::LoadError::FaceParseError => + "Syntax error describing which vertices form a face.", + tobj::LoadError::MaterialParseError => + "Syntax error describing a rendering material.", + tobj::LoadError::InvalidObjectName => + "Syntax error in the name of an object.", + tobj::LoadError::InvalidPolygon => + "Geometric error with an alleged polygon.", + tobj::LoadError::FaceVertexOutOfBounds => + "Geometric error with a vertex's location.", + tobj::LoadError::FaceTexCoordOutOfBounds => + "Geometric error with texture coordinates.", + tobj::LoadError::FaceNormalOutOfBounds => + "Geometric error with a normal vector.", + tobj::LoadError::FaceColorOutOfBounds => + "Geometric error with a vertex color (yes).", + tobj::LoadError::InvalidLoadOptionConfig => + "Invoked incorrectly by Surreality.", + tobj::LoadError::GenericFailure => + "The library's author didn't choose to tell us why.", + }) + } + } +} + + pub fn ignore_errors(mut body: impl FnMut() -> Result<()>) -> () { if let Err(e) = body() { eprintln!("Error: {}", e); -- cgit 1.4.1