Skip to content

Standardise on when exceptions are thrown and when callbacks are used #266

@mattheworiordan

Description

@mattheworiordan

See https://github.com/ably/ably-java/blob/master/lib/src/main/java/io/ably/lib/realtime/Channel.java#L494-L497

The publish method can raise an AblyException, but also has a completionListener which handles success & failure conditions.

Now if you look at https://goo.gl/Hc0yqK, you can see that if a channel is in invalid state we raise an exception, yet if RTL6c3 was implemented correctly it should fail it the channel becomes FAILED / SUSPENDED before the message is published.

IMHO this is wrong and confusing for developers. See ably/ably-ruby@92686ae where I have changed this in Ruby, and https://github.com/ably/wiki/issues/175 (points 6 & 7).

I believe our policy for async methods / methods with callbacks should be that if the arguments provided are invalid then raise an exception, otherwise any exceptions relating to the state of the library or future state of the library should be passed as a failure argument in the callback

┆Issue is synchronized with this Jira Task by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improved functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions