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

Add error trace to Functions with xpcall #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Tazmondo
Copy link
Contributor

@Tazmondo Tazmondo commented Jan 9, 2024

Not sure what your stance on this is, but I personally think it's good for DX so I figured I'd make a PR and you can decide whether to merge or close.
There's no pressure at all to respond quickly - I know you're preoccupied with thinking about zap so feel free to come back to this later.
The code isn't particularly long so there's nothing lost if it isn't merged.

For reference, evaera's promise library uses xpcall for its stack traces so it's a battle tested method for this sort of thing.

@Tazmondo
Copy link
Contributor Author

Tazmondo commented Jan 9, 2024

Error appearance:
image
image

With corresponding callback body:

ErrorFunction:SetCallback(function(Player)
	assert(1 == 2, "Assert failed.") -- Line 36
	return ""
end)

however this will emit warnings for people who use the silent erroring intentionally so it's not ideal
@Tazmondo
Copy link
Contributor Author

Tazmondo commented Jan 13, 2024

Summarizing the conversation on discord regarding this PR:

People may rely on the pattern of a function silently erroring on the server and returning that error with its value to the client.
But this change would cause a warning to be emitted every time the function errors with a string value (even when intentional).
So it's not necessarily a breaking change but it's not a simple improvement to merge in.

Perhaps we could add this as an option when creating Functions, similar to how you can set whether an event is reliable or unreliable? Like SilenceErrors: boolean? or something.

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.

1 participant