소스 검색

throw error when failed to load image

nagadomi 10 년 전
부모
커밋
1cdceb1648
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      lib/image_loader.lua

+ 6 - 0
lib/image_loader.lua

@@ -45,12 +45,18 @@ function image_loader.decode_byte(blob)
 end
 function image_loader.load_float(file)
    local fp = io.open(file, "rb")
+   if not fp then
+      error(file .. ": failed to load image")
+   end
    local buff = fp:read("*a")
    fp:close()
    return image_loader.decode_float(buff)
 end
 function image_loader.load_byte(file)
    local fp = io.open(file, "rb")
+   if not fp then
+      error(file .. ": failed to load image")
+   end
    local buff = fp:read("*a")
    fp:close()
    return image_loader.decode_byte(buff)