Skip to content

Commit

Permalink
Improve error message when type isn't found.
Browse files Browse the repository at this point in the history
  • Loading branch information
player-03 committed Oct 20, 2023
1 parent 72e0b48 commit ec96d6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/echoes/macro/MacroTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ class MacroTools {
return followMono(e.typeof()).toComplexType();
} catch(err:Exception) { }

Context.error('Failed to parse `${ new Printer().printExpr(e) }`. Try making a typedef or using the special type check syntax: `entity.get((_:MyType))` instead of `entity.get(MyType)`.', e.pos);
var expr:String = new Printer().printExpr(e);
if(~/^[\w\d\.]+$/.match(expr)) {
Context.error('Type not found: `$expr`.', e.pos);
} else {
Context.error('Failed to parse type `$expr`. Try using the special type check syntax, e.g. `entity.get((_:$expr))` instead of `entity.get($expr)`.', e.pos);
}

return macro:Dynamic;
}

Expand Down

0 comments on commit ec96d6e

Please sign in to comment.