Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

More accurate error messages when failing to set properties #315

Merged
merged 5 commits into from
Feb 10, 2024
Merged

More accurate error messages when failing to set properties #315

merged 5 commits into from
Feb 10, 2024

Conversation

mskfox
Copy link
Contributor

@mskfox mskfox commented Feb 6, 2024

In reference to #249

@mskfox
Copy link
Contributor Author

mskfox commented Feb 6, 2024

The new message (following the example from issue #249) looks like this, thus no longer providing false information to the developer.

image

@mskfox
Copy link
Contributor Author

mskfox commented Feb 6, 2024

Instead of [Fusion] 'UIAspectRatioConstraint.AspectRatio' expected a 'number' type, but got a 'number' type. (ID: invalidPropertyType)

@dphfox
Copy link
Owner

dphfox commented Feb 7, 2024

This seems overly verbose; I would suggest trimming down the message significantly. The error message duplicates information about what property was set on what instance, so we don't need to include it ourselves.

I would suggest: Error setting property: ERROR_MESSAGE

Same for the ID; it'd be better off as propertySetError to save space. It still communicates the same meaning.

Other than that, this change seems to be fine.

@dphfox dphfox linked an issue Feb 7, 2024 that may be closed by this pull request
@dphfox dphfox changed the title Enhance capability to handle property assignment failures (should 😅) More accurate error messages when failing to set properties Feb 7, 2024
@mskfox
Copy link
Contributor Author

mskfox commented Feb 7, 2024

This looks good, we can also combine the two error messages if needed. Initially, I didn't do it because Fusion might prefer having them separate for clearer documentation on different error types.

local function setProperty(instance: Instance, property: string, value: any)
	local success, err = xpcall(setProperty_unsafe, parseError, instance, property, value)

	if not success then
		if not pcall(testPropertyAssignable, instance, property) then
			-- ...
		else
			-- invalidPropertyType no longer used
			logError("propertySetError", err)
		end
	end
end

What's your take on this?

@dphfox
Copy link
Owner

dphfox commented Feb 8, 2024

I think it's fine to keep the invalidPropertyType error.

@mskfox
Copy link
Contributor Author

mskfox commented Feb 8, 2024

Alright, all the issues should be patched.

@dphfox dphfox merged commit d34839d into dphfox:main Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalidPropertyType error when types match
2 participants