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

Throw errors instead of returning null when serialization/ deserialization fails #149

Closed
ben-xD opened this issue Aug 10, 2021 · 2 comments · Fixed by #409
Closed

Throw errors instead of returning null when serialization/ deserialization fails #149

ben-xD opened this issue Aug 10, 2021 · 2 comments · Fixed by #409
Labels
enhancement New feature or improved functionality.

Comments

@ben-xD
Copy link
Contributor

ben-xD commented Aug 10, 2021

In Java, if serialization/ deserialization fails, instead of propagating the error, it is logged and ignored, and null is returned instead. For example:

private ChannelOptions decodeRestChannelOptions(Map<String, Object> jsonMap) {
if (jsonMap == null) return null;
final Object cipher = jsonMap.get(PlatformConstants.TxRealtimeChannelOptions.cipher);
try {
return ChannelOptions.withCipherKey((String) cipher);
} catch (AblyException ae) {
System.out.println("Exception while decoding RestChannelOptions : " + ae);
return null;
}
}

It would be nicer during development to have an exception be thrown when serialization fails. We should consider throwing an exception when serialization/ deserialization fails.

┆Issue is synchronized with this Jira Story by Unito

@ben-xD ben-xD changed the title Throw errors instead of returning null in serialization/ deserialization code Throw errors instead of returning null when serialization/ deserialization fails Aug 10, 2021
@ben-xD ben-xD added the enhancement New feature or improved functionality. label Aug 25, 2021
@QuintinWillison
Copy link
Contributor

See this comment.

@ikurek
Copy link
Contributor

ikurek commented May 18, 2022

Working link to mentioned comment: #140 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improved functionality.
Development

Successfully merging a pull request may close this issue.

3 participants