-
Notifications
You must be signed in to change notification settings - Fork 98
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 support for throwing errors with custom error code #272
Conversation
Hey @palamccc thanks for the contribution! Would you be able to add tests for your changes? Looks like Additionally the DCO check will ideally need to be resolved before this can be merged. |
@@ -943,3 +943,11 @@ function deserializeMetadataPushPayload<D, M>( | |||
metadata: serializers.metadata.deserialize(frame.metadata), | |||
}; | |||
} | |||
|
|||
export class RSocketError extends Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be best as its own file RSocketError.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍🏽
Signed-off-by: palani <palam.c@gmail.com>
Signed-off-by: palani <palam.c@gmail.com>
Signed-off-by: palani <palam.c@gmail.com>
Signed-off-by: palani <palam.c@gmail.com>
227ccf9
to
cd30156
Compare
@viglucci I've added tests now. |
LGTM. Thanks! I'll LYK when a new version is published. |
I've contributed types to DefinitelyTyped DefinitelyTyped/DefinitelyTyped#68788 |
@palamccc I've published a new version which should include this change. If you would be so kind, please validate this change with |
Motivation:
In the rsocket-js implementation (v0 branch), all stream errors are serialized and transmitted to other end with fixed error code. Due to this bug, there is no way to send custom error codes over stream (Bug report #218)
Custom error codes are supported in the rsocket protocol and implemented in rsocket-java this using RSocketErrorException . When the application throws
RSocketErrorExecption
, the error code of the exception is sent over the stream. But this feature is not implemented in rsocket-js.Modifications:
RSocketError
inRSocketError.js
.RSocketError
, theerrorCode
of the error object is sent over the stream.Result:
This will allow application to send custom error codes to other party.