[provider] return null instead throw error
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
<source path="src"/>
|
||||
<assets path="src" rename="image" include="*.png"/>
|
||||
|
||||
<haxelib name="lime" version="7.2.1"/>
|
||||
<haxelib name="openfl" version="8.8.0"/>
|
||||
<haxelib name="lime" version="7.3.0"/>
|
||||
<haxelib name="openfl" version="8.9.0"/>
|
||||
<haxelib name="hxcpp" version="4.0.8"/>
|
||||
<haxelib name="promhx" version="1.1.0"/>
|
||||
<haxelib name="yaml" version="1.3.0"/>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package haxework.macro;
|
||||
|
||||
import haxe.DynamicAccess;
|
||||
|
||||
class PositionYamlParser {
|
||||
|
||||
private var filename:String;
|
||||
@@ -18,16 +20,16 @@ class PositionYamlParser {
|
||||
parseBlock(result);
|
||||
}
|
||||
|
||||
private function parseBlock(result:Dynamic):Void {
|
||||
for (field in Reflect.fields(result)) {
|
||||
private function parseBlock(result:DynamicAccess<Dynamic>):Void {
|
||||
for (field in result.keys()) {
|
||||
var offset = content.indexOf(field, cache.get(field));
|
||||
cache.set(field, offset);
|
||||
Reflect.setField(result, "$" + field, {
|
||||
result.set("$" + field, {
|
||||
min:offset,
|
||||
max:offset + field.length,
|
||||
file:filename,
|
||||
});
|
||||
var value = Reflect.field(result, field);
|
||||
var value = result.get(field);
|
||||
if (Std.is(value, Array)) {
|
||||
for (item in cast(value, Array<Dynamic>)) {
|
||||
parseBlock(item);
|
||||
@@ -38,7 +40,7 @@ class PositionYamlParser {
|
||||
}
|
||||
}
|
||||
|
||||
public static function parse(filename:String, content:String, result:Dynamic):Void {
|
||||
public static inline function parse(filename:String, content:String, result:Dynamic):Void {
|
||||
new PositionYamlParser(filename, content, result).parseAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class Provider {
|
||||
instances.set(key, instance);
|
||||
return instance;
|
||||
} else {
|
||||
throw 'Factory for "${key}" not found';
|
||||
return null;
|
||||
//throw 'Factory for "${key}" not found';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user