浏览代码

added NotFound exception

ncannasse 11 年之前
父节点
当前提交
0f758ca959
共有 3 个文件被更改,包括 15 次插入4 次删除
  1. 2 2
      hxd/res/EmbedFileSystem.hx
  2. 2 2
      hxd/res/LocalFileSystem.hx
  3. 11 0
      hxd/res/NotFound.hx

+ 2 - 2
hxd/res/EmbedFileSystem.hx

@@ -229,11 +229,11 @@ class EmbedFileSystem #if !macro implements FileSystem #end {
 		#if flash
 		var f = open(path);
 		if( f == null && !isDirectory(path) )
-			throw "File not found " + path;
+			throw new NotFound(path);
 		return new EmbedEntry(this, path.split("/").pop(), path, f);
 		#else
 		if( !exists(path) )
-			throw "File not found " + path;
+			throw new NotFound(path);
 		var id = resolve(path);
 		return new EmbedEntry(this, path.split("/").pop(), path, id);
 		#end

+ 2 - 2
hxd/res/LocalFileSystem.hx

@@ -278,12 +278,12 @@ class LocalFileSystem implements FileSystem {
 		#if air3
 		var f = open(path);
 		if( f == null || !f.exists )
-			throw "File not found " + path;
+			throw new NotFound(path);
 		return new LocalEntry(this, path.split("/").pop(), path, f);
 		#else
 		var f = open(path);
 		if( f == null ||!sys.FileSystem.exists(f) )
-			throw "File not found " + path;
+			throw new NotFound(path);
 		return new LocalEntry(this, path.split("/").pop(), path, f);
 		#end
 	}

+ 11 - 0
hxd/res/NotFound.hx

@@ -0,0 +1,11 @@
+package hxd.res;
+
+class NotFound {
+	public var path : String;
+	public function new(path) {
+		this.path = path;
+	}
+	@:keep function toString() {
+		return "Resource file not found '" + path + "'";
+	}
+}