Skip to content

JSON RPC server callback return types post #708 cleanup #832

Closed Answered by stephenberry
majorpain1588 asked this question in Q&A
Discussion options

You must be logged in to vote

Fixed in #834

Example:

server.on<"foo">(
  [](const foo_params& params) -> glz::expected<foo_result, glz::rpc::error>
  {
      if (params.foo_a == 10) // dummy invalid param case
      {
          return glz::unexpected(glz::rpc::error{glz::rpc::error_e::invalid_params, "my error"});
      }
      else
      {
          return foo_result{.foo_c = true, .foo_d = "new world"};
      }
  }
);

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stephenberry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants