Skip to content

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