trace-server-protocol icon indicating copy to clipboard operation
trace-server-protocol copied to clipboard

Errors are specified as strings, while clients expect json

Open tahini opened this issue 4 years ago • 4 comments

the tsp-typescript-client tries to convert to json any response they get from the server. But some of the error messages, like when putting an invalid trace, return as text strings.

This causes like this in the theia-trace-extension:

Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data openTrace tsp-client.ts:55 tryOpen trace-manager.ts:76

We should either:

1- Document all error messages to be json, like {message: string} in the protocol and have the server return them this way

or

2- Have the tsp-typescript-client verify the response code before trying to convert to json and have the consumers do likewise whe processing responses

What do you think?

tahini avatar Dec 14 '20 17:12 tahini

I would hard code it as JSON at the moment. It makes sense to have structured errors.

Thoughts?

MatthewKhouzam avatar Dec 14 '20 18:12 MatthewKhouzam

+1 for json messages. For now, we can have the server return json messages and update the protocol soon-ish

tahini avatar Dec 15 '20 15:12 tahini

Related pull request in tsp-typescript-client: https://github.com/theia-ide/tsp-typescript-client/pull/15. With that change it's OK not to have a <T> json model in the response, and the plain text response will be available to the caller.

PatrickTasse avatar Dec 21 '20 19:12 PatrickTasse

Related PR in trace server: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/173840

Additional failsafe in tsp client is good

tahini avatar Dec 21 '20 19:12 tahini