Skip to content

feat: implement builder pattern for JsonrpcErrorError #18

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

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

hashemix
Copy link
Member

📌 Summary

To improve usability and maintainability, we've introduced a new approach for creating JsonrpcErrorError objects using a builder pattern. This makes the API more ergonomic and allows method chaining.

✨ Changes Made

  • Enhanced schema_utils by adding a builder pattern to JsonrpcErrorError.
  • Deprecated the get_method() functions in favor of method() to improve consistency.

💡 Additional Notes

The new functionalities make creating a JsonrpcErrorError object much easier.

Old Approach

JsonrpcErrorError::new(
            schema_utils::RpcErrorCodes::method_not_found,
            "Method not found!".to_string(),
            None,
        );

New Approach

JsonrpcErrorError::method_not_found()
  • overriding the message and passing data:
JsonrpcErrorError::method_not_found()
        .with_message("Method is not supported!".to_string())
        .with_data(Some(json!({"details": "No implementation found for this method."})))

@hashemix hashemix self-assigned this Feb 14, 2025
@hashemix hashemix merged commit 71e63e5 into main Feb 14, 2025
2 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.

1 participant