Skip to content

Conversation

@dmitrylavrenov
Copy link
Contributor

Closes #332

The details of JsonRpseeError - https://github.com/paritytech/jsonrpsee/blob/f83c6c55a8e2c36172cea8a5c1145e9a3b9ab377/core/src/error.rs#L57

Found 2 options to create JsonRpseeError:

At the current moment I've implemented an example with first option as it's not required a lot of additional codes with our current implementation.

@MOZGIII What do you think? Can I continue with the first one?

@dmitrylavrenov dmitrylavrenov linked an issue Dec 14, 2022 that may be closed by this pull request
@MOZGIII
Copy link
Contributor

MOZGIII commented Dec 14, 2022

The problem with error creation is not that it's too verbose, but rather that we don't have a proper contract between our UI and the RPC server to be able to display the errors with a sensible custom logic.

@MOZGIII
Copy link
Contributor

MOZGIII commented Dec 14, 2022

Let's discuss with @sesh92

@MOZGIII
Copy link
Contributor

MOZGIII commented Jan 5, 2023

@sesh92, @dmitrylavrenov let's spend some time on this

@dmitrylavrenov dmitrylavrenov reopened this Jan 9, 2023
@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from a79d633 to b5e21be Compare January 10, 2023 18:40
@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from b5e21be to 427e927 Compare January 10, 2023 18:40
@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch 2 times, most recently from eec29a9 to 956b488 Compare January 10, 2023 19:50
@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from 956b488 to ebbe219 Compare January 10, 2023 19:53
@MOZGIII
Copy link
Contributor

MOZGIII commented Jan 11, 2023

Please make sure we don't lose existing error message string customizations when we migrate to the new errors. We still need them.

@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from c01ff6c to 634610f Compare January 11, 2023 10:33
@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from 634610f to e0d27c4 Compare January 11, 2023 10:35
@MOZGIII
Copy link
Contributor

MOZGIII commented Jan 27, 2023

I think this needs more work but we need other things done. Let's put this on hold and move on. I also need some time to capture our requirements here more precisely, so we probably should not waste our time bashing this over and over.

Alternatively, we can merge as-is, but it might be worse than where we started... In a sense that what we had before was clearly a mess, but it was compact and could be helped relatively simply with helpers. This has some logic in it, but no explicit constraints, and is much more verbose. Yet it still feels like the logic is not clear on how we would implement this, to me it feels like reading the code from the position of the frontend engineer has become even more difficult.


To sum up what I've figured here so far:

  1. We really care about the error data, shapes of the error data must be well-defined, and must be specified per method at the type-system level via an enum (or struct if need be) of all possible values.
  2. The errors that don't have associated error data shapes are all the same to the client - in the sense that they have the same shape of message and error code. These can be described universally via a single type, and there's no need for custom data there.
  3. We need to ensure the decision-making logic about the error data shapes is not nested or layered within the error implementations.
  4. To enforce the compiler to complain, we cannot implement From<_> for JsonRpseeError for the types that are not considered top-level method error enums.
  5. We probably don't want to implement From<_> for JsonRpseeError manually at all, and only allow a generic impl<T> From<T> for JsonRpseeError where T: SomeCustomTraitOfOurs, such that we have to implement SomeCustomTraitOfOurs and just implement SomeCustomTraitOfOurs for our error types, and implement the JsonRpseeError construction logic based on SomeCustomTraitOfOurs implementations.

Anyhow, this one task has taken us too much effort already, so let's put a pin in it.

We might want to do a prototype with (5), but we have better ways to spend our time now, as this is not a blocker for anyone.

@MOZGIII
Copy link
Contributor

MOZGIII commented Jan 28, 2023

@dmitrylavrenov I managed to fix most of the issues I observed while writing #539 (comment), please check out my changes and adjust the rest of the codebase accordingly.

@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from b85d61e to d7376b7 Compare January 31, 2023 14:53
@MOZGIII
Copy link
Contributor

MOZGIII commented Feb 1, 2023

How come we have merge conflicts? Let's fix them!

Copy link
Contributor

@MOZGIII MOZGIII left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

@dmitrylavrenov dmitrylavrenov force-pushed the jsonrpseeerror-creation branch from bd3ebc4 to 6bc2148 Compare February 2, 2023 11:14
@dmitrylavrenov dmitrylavrenov merged commit 0d5518c into master Feb 3, 2023
@dmitrylavrenov dmitrylavrenov deleted the jsonrpseeerror-creation branch February 3, 2023 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Look into the way of JsonRpseeError creation

3 participants