diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-07-20 20:43:48 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-07-20 20:43:48 -0700 |
| commit | 3ac1e5e5a9ebcb4beb2bfe149dd5095f2250f60d (patch) | |
| tree | d409eb8dfcca1b56dffe8c143a2c9028818d6d5d /src/error.rs | |
| parent | 365c2f8bdc217f33264e3aed394f67840a4c075d (diff) | |
yay Force-Push: yes Change-Id: Icb715692286c8560532ab73d32a49be8f485d790
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); |