flixel-ui icon indicating copy to clipboard operation
flixel-ui copied to clipboard

The error when the xml file is not found / parsable is not easy to understand

Open sebbernery opened this issue 9 years ago • 7 comments

Hi ! When I create a FlxUIState, I set the _xml_id with a filename. If this file does not exists (typo in the name, added the ".xml" to the filename, ...) or if it's not parsable (error in the XML), here is the error I get :

Invalid field access : h
Called from flixel/addons/ui/FlxUI.hx line 1354
Called from flixel/addons/ui/FlxUITooltipManager.hx line 63 
Called from flixel/addons/ui/FlxUIState.hx line 206
...

It's very hard to debug. It could be interesting to have an error more explicit.

sebbernery avatar Dec 01 '15 21:12 sebbernery

That's a haxe error, not a flixel error. But sure, having an actual error message would be good.

MSGhero avatar Dec 02 '15 03:12 MSGhero

It's not possible to just look if _xml_id terminate with a .xml and throw an exception with a more explicit message ? Else, i have the same error when I make a mistake on my xml such missing a /.

Blist avatar Dec 02 '15 09:12 Blist

Checking for the file ending sounds like a bad idea, there shouldn't be anything stopping your from having an xml file that doesn't end with .xml.

Gama11 avatar Dec 03 '15 19:12 Gama11

It's not possible to handle both file with or without .xml ? and check both with the File exists api ?

Blist avatar Dec 03 '15 20:12 Blist

Sure, which is why your suggestion to check for the .xml ending didn't make sense to me. :)

just look if _xml_id terminate with a .xml and throw an exception

Gama11 avatar Dec 03 '15 20:12 Gama11

Yeah, but in the documentation, it's say

_xml_id = "state_battle"; //looks for "state_battle.xml"

So, i don't know if flixel ui permit an _xml_id terminate with .xml, if not we need to thown an exception if the _xml_id, no ?

However I'm agree with you, the better way, its to load and permit an xml_id with ou without the xml extension.

Blist avatar Dec 03 '15 20:12 Blist

The issue here is that there are checks in place already, but something else is happening, resulting in this obscure error. I think it has to do with initializing the tooltip manager.

larsiusprime avatar Dec 03 '15 21:12 larsiusprime