-
Notifications
You must be signed in to change notification settings - Fork 171
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
Introduce the jsonrpc.Error interface #1236
Conversation
7bb5bde
to
2001459
Compare
Allows for custom error types.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1236 +/- ##
==========================================
+ Coverage 73.71% 73.75% +0.03%
==========================================
Files 70 70
Lines 7530 7541 +11
==========================================
+ Hits 5551 5562 +11
Misses 1523 1523
Partials 456 456
☔ View full report in Codecov by Sentry. |
I will read thru the changes tomorrow but;
|
We convert everything to a
So we don't need to modify global error variables, and can create custom types where necessary. |
When would that be necessary? |
When we need dynamic error messages (see second commit for examples). |
Error messages are not dynamically created by the interface tho, they are set at the time of instantiation. You are essentially using it the interface as simple getters. Such an interface only makes sense to me if the caller (ie jsonrpc.Server) benefits from being able to cast the interface to original concrete error type and makes use of its internal fields and the functions of the interface is generating value (error messages or data) from those fields. I am not sure I see a case where this would be required and be immediately useful for us. I would love to hear what others think as well. cc: @kirugan @IronGauntlets |
Happy to hear what others think as well.
Right now, we instantiate global error variables, which precludes us from mutating messages when the spec requires it. |
We create local copies of them to be mutated when needed. Is there anything obviously wrong with this that I am missing? |
We copy the pointer and mutate the underlying value. Even if we copied the value, it would be sub-optimal since |
We copy the value here, no?
They are not generic |
Yes we do copy it there. Here we do not. Even if we decide the interface isn't necessary, I can fix that in this PR :)
Ah yes you're right. Maybe they should be though? For client-facing projects like starknet.go, being able to use |
Allows for custom error types.