summary refs log tree commit diff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index f034683..729ff23 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -90,6 +90,31 @@ impl From<vulkanalia::bytecode::BytecodeError> for Error {
   }
 }
 
+impl From<std::io::Error> for Error {
+  fn from(e: std::io::Error) -> Self {
+    Error {
+      message: format!("System I/O error: {}", e),
+    }
+  }
+}
+
+impl From<png::DecodingError> for Error {
+  fn from(e: png::DecodingError) -> Self {
+    match e {
+      png::DecodingError::IoError(e) => Self::from(e),
+      png::DecodingError::Format(_) => Error {
+        message: "Texture image is not a valid PNG.".to_string(),
+      },
+      png::DecodingError::Parameter(e) => Error {
+        message: format!("PNG library misusage: {}", e),
+      },
+      png::DecodingError::LimitsExceeded => Error {
+        message: "PNG needed too much memory to decode.".to_string(),
+      }
+    }
+  }
+}
+
 pub fn ignore_errors(mut body: impl FnMut() -> Result<()>) -> () {
   if let Err(e) = body() {
     eprintln!("Error: {}", e);