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

Fix #397. Call callback instead of throwing AblyException #398

Merged
merged 4 commits into from Feb 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/IO.Ably.Shared/Realtime/Presence.cs
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using IO.Ably.Transport;
using IO.Ably.Types;
using IO.Ably.Utils;
using Newtonsoft.Json.Linq;

namespace IO.Ably.Realtime
Expand Down Expand Up @@ -469,11 +470,13 @@ internal void UpdatePresence(PresenceMessage msg, Action<bool, ErrorInfo> callba
case ConnectionState.Connected:
break;
default:
throw new AblyException(
new ErrorInfo(
$"Unable to enter presence channel when connection is in a ${_connection.Connection.State} state",
91001,
HttpStatusCode.BadRequest));
var error = new ErrorInfo(
$"Unable to enter presence channel when connection is in a ${_connection.Connection.State} state.",
91001,
HttpStatusCode.BadRequest);
Logger.Warning(error.ToString());
ActionUtils.SafeExecute(() => callback?.Invoke(true, error), Logger, nameof(UpdatePresence));
break;
}

switch (_channel.State)
Expand All @@ -495,7 +498,10 @@ internal void UpdatePresence(PresenceMessage msg, Action<bool, ErrorInfo> callba
_connection.Send(message, callback);
break;
default:
throw new AblyException($"Unable to enter presence channel in {_channel.State} state", 91001, HttpStatusCode.BadRequest);
var error = new ErrorInfo($"Unable to enter presence channel in {_channel.State} state", 91001);
Logger.Warning(error.ToString());
ActionUtils.SafeExecute(() => callback?.Invoke(true, error), Logger, nameof(UpdatePresence));
break;
}
}

Expand Down