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

Forward error types as their string representation #131

Merged

Conversation

sthelen-enqs
Copy link
Contributor

By default go serializes error types as an empty struct {}, this patch would adjust that so that errors are serialized as their string representation by calling Error() on any non-nil types that implement the error interface.

This should be an improvement over the current state as it now allows identifying the cause of an error from the RPC client. An alternative could be to serialize the error as a struct of {"type": <>, "message": <>} using reflection to get the type name (and package path) of the error though I'm not sure if it's necessary and I'd have to check how easy that would be to get working.

@DerAndereAndi
Copy link
Member

I think providing the error as a string representation is just fine. In the stack the error is always defined as a string and a type is never used.

@sthelen-enqs sthelen-enqs marked this pull request as ready for review October 30, 2024 12:10
@sthelen-enqs
Copy link
Contributor Author

In that case I'll mark this as ready for review unless anyone else has any comments

@DerAndereAndi DerAndereAndi merged commit 73d0d7f into enbility:feature/jsonrpc2 Nov 2, 2024
3 checks passed
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.

2 participants