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 helpers for formatting JSON CDP responses #43340

Closed
wants to merge 1 commit into from

Commits on Mar 6, 2024

  1. Add helpers for formatting JSON CDP responses (facebook#43340)

    Summary:
    Pull Request resolved: facebook#43340
    
    Adds convenience methods `jsonResult`, `jsonError` and `jsonNotification` for more ergonomic construction of CDP JSON responses. Note that CDP is *loosely* based on [JSON-RPC 2.0](https://www.jsonrpc.org/specification), but differs for example in the  omission of `"jsonrpc": "2.0"`.
    
    Before:
    ```
    frontendChannel_(folly::toJson(folly::dynamic::object("id", req.id)(
                "error",
                folly::dynamic::object("code", -32602)(
                    "message",
                    "executionContextName is mutually exclusive with executionContextId"))));
    ```
    
    After:
    ```
    frontendChannel_(cdp::jsonError(
                req.id,
                cdp::ErrorCode::InvalidParams,
                "executionContextName is mutually exclusive with executionContextId"));
    ```
    
    Changelog: [Internal]
    
    Reviewed By: motiz88
    
    Differential Revision: D54202854
    robhogan authored and facebook-github-bot committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    50223c7 View commit details
    Browse the repository at this point in the history