浏览代码

Catch image decoding errors and show filepath

trethaller 6 年之前
父节点
当前提交
8c6bb374b3
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      hide/comp/Scene.hx

+ 7 - 3
hide/comp/Scene.hx

@@ -395,9 +395,13 @@ class Scene extends Component implements h3d.IDrawable {
 			hxd.res.Any.fromBytes(path, bytes);
 		};
 		if( onReady == null ) onReady = function(_) {};
-		t = loadTextureData(res.toImage(), onReady, t);
-		t.name = ide.makeRelative(path);
-		texCache.set(path, t);
+		try {
+			t = loadTextureData(res.toImage(), onReady, t);
+			t.name = ide.makeRelative(path);
+			texCache.set(path, t);
+		} catch( error : Dynamic ) {
+			throw "Could not load texure " + texturePath + ":\n" + Std.string(error);
+		};
 		return t;
 	}