Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make Resource loading less error prone from capitalization #325

Open
nightm4re94 opened this issue Mar 26, 2020 · 0 comments
Open

Make Resource loading less error prone from capitalization #325

nightm4re94 opened this issue Mar 26, 2020 · 0 comments

Comments

@nightm4re94
Copy link
Member

When I accidentally tried to load a TmxMap "lab" instead of its actual name "Lab", I got very misleading Error messages because the XML parser tried to parse the directory "lab" instead of the contained "Lab.tmx". Maybe we should include a mechanism to prevent this kind of misunderstanding and check for lowercased matches in the project Resources.

Thu Mar 26 18:02:34 CET 2020 Main Update Loop threw an exception:
de.gurkenlabs.litiengine.resources.ResourceLoadException: de.gurkenlabs.litiengine.environment.tilemap.xml.TmxException
	at de.gurkenlabs.litiengine.resources.ResourcesContainer.loadResource(ResourcesContainer.java:391)
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1688)
	at de.gurkenlabs.litiengine.resources.ResourcesContainer.get(ResourcesContainer.java:273)
	at de.gurkenlabs.litiengine.resources.ResourcesContainer.get(ResourcesContainer.java:207)
	at de.gurkenlabs.litiengine.environment.GameWorld.getEnvironment(GameWorld.java:315)
	at de.gurkenlabs.litiengine.environment.GameWorld.loadEnvironment(GameWorld.java:420)
	at de.gurkenlabs.drlepus.GameSession.lambda$1(GameSession.java:74)
	at de.gurkenlabs.litiengine.GameLoop.executeTimedActions(GameLoop.java:104)
	at de.gurkenlabs.litiengine.GameLoop.process(GameLoop.java:83)
	at de.gurkenlabs.litiengine.UpdateLoop.run(UpdateLoop.java:57)
Caused by: de.gurkenlabs.litiengine.environment.tilemap.xml.TmxException
	at de.gurkenlabs.litiengine.resources.Maps.load(Maps.java:31)
	at de.gurkenlabs.litiengine.resources.Maps.load(Maps.java:1)
	at de.gurkenlabs.litiengine.resources.ResourcesContainer.loadResource(ResourcesContainer.java:389)
	... 9 more
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; systemId: file:/D:/Git/drlepus/bin/main/lab; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.]
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:548)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:234)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:199)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:162)
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:171)
	at de.gurkenlabs.litiengine.util.io.XmlUtilities.read(XmlUtilities.java:94)
	at de.gurkenlabs.litiengine.resources.Maps.load(Maps.java:29)
	... 11 more
Caused by: org.xml.sax.SAXParseException; systemId: file:/D:/Git/drlepus/bin/main/lab; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:994)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:228)
	... 17 more
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants