The Wayback Machine - https://web.archive.org/web/20201102190234/https://github.com/rsocket/rsocket-java/issues/741
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

Defining behaviour for error data payloads #741

Open
SerCeMan opened this issue Feb 9, 2020 · 3 comments
Open

Defining behaviour for error data payloads #741

SerCeMan opened this issue Feb 9, 2020 · 3 comments
Assignees

Comments

@SerCeMan
Copy link
Contributor

@SerCeMan SerCeMan commented Feb 9, 2020

Hey, Folks!

As far as I can see, rsocket allows for sending arbitrary payloads inside the error frame, Error Data, as long as it's encoded in UTF-8. At the moment, rsocket-java encodes the exception message into the Error Data field.

String message = t.getMessage() == null ? "" : t.getMessage();

I'm planning on using a custom error code to define a "structured" payload which includes a json-encoded object with multiple fields. It's easily achievable by creating a custom rsocket exception, thanks to #727, with a special message, e.g.

byte[] data = mapper.serialize(obj);
return Flux.error(new MyRsocketException(new String(data, "UTF-8"));

However, the way of doing this isn't well-defined, and the behaviour might change in future. What do you think of defining this behaviour explicitly, similarly to this POC: SerCeMan@1c7df73? Alternatively, maybe it would be better to add javadoc documenting the behaviour on the exception itself.

@OlegDokuka
Copy link
Member

@OlegDokuka OlegDokuka commented Feb 9, 2020

I totally agree that the string representation of the error message is more than useless.

Unfortunately, spec limits body to -> (https://github.com/rsocket/rsocket/blob/master/Protocol.md#error-frame-0x0b)

Error Data: includes Payload describing error information. Error Data SHOULD be a UTF-8 encoded string. The string MUST NOT be null terminated.

So far, I propose to add your input here -> rsocket/rsocket#282

@OlegDokuka OlegDokuka added this to the backlog milestone Apr 5, 2020
@OlegDokuka OlegDokuka self-assigned this Apr 5, 2020
@OlegDokuka OlegDokuka removed this from the 1.x backlog milestone Apr 7, 2020
@SerCeMan
Copy link
Contributor Author

@SerCeMan SerCeMan commented Apr 16, 2020

Hey, Oleg! Thanks! To clarify, at the moment I'm generally happy with the arbitrary payload encoded as an UTF-8 string. The issue that I'm facing is that there is no explicit way for me to specify what should be in this payload through rsocket-java API.

@OlegDokuka
Copy link
Member

@OlegDokuka OlegDokuka commented Apr 16, 2020

Gotcha! Will be refined today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.