diff options
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 42 |
1 files changed, 42 insertions, 0 deletions
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<png::DecodingError> for Error { } } +impl From<tobj::LoadError> 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); |