Skip to content

Make SpriteBank.orig_ctor throw a descriptive error if an element has copy but no path#1100

Open
SilverDorian46 wants to merge 1 commit into
EverestAPI:devfrom
SilverDorian46:sprite-data-copy-no-path-exception
Open

Make SpriteBank.orig_ctor throw a descriptive error if an element has copy but no path#1100
SilverDorian46 wants to merge 1 commit into
EverestAPI:devfrom
SilverDorian46:sprite-data-copy-no-path-exception

Conversation

@SilverDorian46
Copy link
Copy Markdown
Contributor

SpriteData.Add already throws an error with the message "Sprite '" + xmlElement.Name + "': 'path' is missing!",
but in order to do that, the execution has to enter SpriteData.Add first.

at the moment, if the element has copy, then the execution tries to get the value of path through xmlElement.Attr("path") - which doesn't do a null check - and pass it to SpriteData.Add, which happens before SpriteData.Add itself is executed.
hence, if the element has copy but no path, the program throws a vague NullReferenceException.

this PR patches that for the program to check xmlElement.HasAttr("path"), which is essentially a null check, right before the line where it tries to get xmlElement.Attr("path").
if the check returns false, an exception with the message "Sprite '" + xmlElement.Name + "': 'path' is missing!" is thrown.

@maddie480-bot maddie480-bot added the 1: review needed This PR needs 2 approvals to be merged (bot-managed) label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1: review needed This PR needs 2 approvals to be merged (bot-managed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants