Skip to content

Commit 4010997

Browse files
Remove misleading error logs
1 parent 17efbf8 commit 4010997

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

c-sharp-chat/PubnubChatApi/PubnubChatApi/Entities/Chat.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public async Task<ChatOperationResult<Channel>> CreatePublicConversation(string
191191
{
192192
var result = new ChatOperationResult<Channel>("Chat.CreatePublicConversation()", this);
193193
var existingChannel = await GetChannel(channelId).ConfigureAwait(false);
194-
if (!result.RegisterOperation(existingChannel, false))
194+
if (!result.RegisterOperation(existingChannel))
195195
{
196196
Logger.Debug("Trying to create a channel with ID that already exists! Returning existing one.");
197197
result.Result = existingChannel.Result;
@@ -224,7 +224,7 @@ private async Task<ChatOperationResult<CreatedChannelWrapper>> CreateConversatio
224224
}
225225

226226
var existingChannel = await GetChannel(channelId).ConfigureAwait(false);
227-
if (!result.RegisterOperation(existingChannel, false))
227+
if (!result.RegisterOperation(existingChannel))
228228
{
229229
Logger.Debug("Trying to create a channel with ID that already exists! Returning existing one.");
230230
result.Result.CreatedChannel = existingChannel.Result;
@@ -333,7 +333,7 @@ public async Task<ChatOperationResult<Membership>> InviteToChannel(string channe
333333
var result = new ChatOperationResult<Membership>("Chat.InviteToChannel()", this);
334334
//Check if already a member first
335335
var members = await GetChannelMemberships(channelId, filter:$"uuid.id == \"{userId}\"").ConfigureAwait(false);
336-
if (!result.RegisterOperation(members, false) && members.Result.Memberships.Any())
336+
if (!result.RegisterOperation(members) && members.Result.Memberships.Any())
337337
{
338338
//Already a member, just return current membership
339339
result.Result = members.Result.Memberships[0];
@@ -817,7 +817,7 @@ public async Task<ChatOperationResult<User>> CreateUser(string userId, ChatUserD
817817
{
818818
var result = new ChatOperationResult<User>("Chat.CreateUser()", this);
819819
var existingUser = await GetUser(userId).ConfigureAwait(false);
820-
if (!result.RegisterOperation(existingUser, false))
820+
if (!result.RegisterOperation(existingUser))
821821
{
822822
result.Result = existingUser.Result;
823823
return result;

c-sharp-chat/PubnubChatApi/PubnubChatApi/Entities/Data/ChatOperationResult.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ internal ChatOperationResult(string operationName, Chat chat)
2424
/// Registers a single PNResult to this overall Chat Operation Result.
2525
/// Returns pubnubResult.Status.Error
2626
/// </summary>
27-
internal bool RegisterOperation<T>(PNResult<T> pubnubResult, bool logIfError = true)
27+
internal bool RegisterOperation<T>(PNResult<T> pubnubResult)
2828
{
2929
InternalStatuses.Add(pubnubResult.Status);
3030
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status: {chat.PubnubInstance.JsonPluggableLibrary.SerializeToJsonString(pubnubResult.Status)}");
3131
Error = pubnubResult.Status.Error;
3232
if (Error)
3333
{
34-
if (logIfError)
35-
{
36-
chat.Logger.Error($"Chat operation \"{OperationName}\" registered PN Status with error: {pubnubResult.Status.ErrorData.Information}");
37-
}
34+
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status with error: {pubnubResult.Status.ErrorData.Information}");
3835
Exception = pubnubResult.Status.ErrorData.Throwable;
3936
}
4037
return Error;
@@ -44,17 +41,17 @@ internal bool RegisterOperation<T>(PNResult<T> pubnubResult, bool logIfError = t
4441
/// Registers another ChatOperationResult to this ChatOperationResult.
4542
/// Returns otherChatResult.Error
4643
/// </summary>
47-
internal bool RegisterOperation(ChatOperationResult otherChatResult, bool logIfError = true)
44+
internal bool RegisterOperation(ChatOperationResult otherChatResult)
4845
{
4946
foreach (var status in otherChatResult.InternalStatuses)
5047
{
5148
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\": {chat.PubnubInstance.JsonPluggableLibrary.SerializeToJsonString(status)}");
5249
InternalStatuses.Add(status);
5350

5451
}
55-
if (otherChatResult.Error && logIfError)
52+
if (otherChatResult.Error)
5653
{
57-
chat.Logger.Error($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\" with error: {otherChatResult.Exception.Message}");
54+
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\" with error: {otherChatResult.Exception.Message}");
5855
}
5956
Exception = otherChatResult.Exception;
6057
Error = otherChatResult.Error;

unity-chat/PubnubChatUnity/Assets/PubnubChat/Runtime/PubnubChatApi/Entities/Chat.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public async Task<ChatOperationResult<Channel>> CreatePublicConversation(string
191191
{
192192
var result = new ChatOperationResult<Channel>("Chat.CreatePublicConversation()", this);
193193
var existingChannel = await GetChannel(channelId).ConfigureAwait(false);
194-
if (!result.RegisterOperation(existingChannel, false))
194+
if (!result.RegisterOperation(existingChannel))
195195
{
196196
Logger.Debug("Trying to create a channel with ID that already exists! Returning existing one.");
197197
result.Result = existingChannel.Result;
@@ -224,7 +224,7 @@ private async Task<ChatOperationResult<CreatedChannelWrapper>> CreateConversatio
224224
}
225225

226226
var existingChannel = await GetChannel(channelId).ConfigureAwait(false);
227-
if (!result.RegisterOperation(existingChannel, false))
227+
if (!result.RegisterOperation(existingChannel))
228228
{
229229
Logger.Debug("Trying to create a channel with ID that already exists! Returning existing one.");
230230
result.Result.CreatedChannel = existingChannel.Result;
@@ -333,7 +333,7 @@ public async Task<ChatOperationResult<Membership>> InviteToChannel(string channe
333333
var result = new ChatOperationResult<Membership>("Chat.InviteToChannel()", this);
334334
//Check if already a member first
335335
var members = await GetChannelMemberships(channelId, filter:$"uuid.id == \"{userId}\"").ConfigureAwait(false);
336-
if (!result.RegisterOperation(members, false) && members.Result.Memberships.Any())
336+
if (!result.RegisterOperation(members) && members.Result.Memberships.Any())
337337
{
338338
//Already a member, just return current membership
339339
result.Result = members.Result.Memberships[0];
@@ -817,7 +817,7 @@ public async Task<ChatOperationResult<User>> CreateUser(string userId, ChatUserD
817817
{
818818
var result = new ChatOperationResult<User>("Chat.CreateUser()", this);
819819
var existingUser = await GetUser(userId).ConfigureAwait(false);
820-
if (!result.RegisterOperation(existingUser, false))
820+
if (!result.RegisterOperation(existingUser))
821821
{
822822
result.Result = existingUser.Result;
823823
return result;

unity-chat/PubnubChatUnity/Assets/PubnubChat/Runtime/PubnubChatApi/Entities/Data/ChatOperationResult.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ internal ChatOperationResult(string operationName, Chat chat)
2424
/// Registers a single PNResult to this overall Chat Operation Result.
2525
/// Returns pubnubResult.Status.Error
2626
/// </summary>
27-
internal bool RegisterOperation<T>(PNResult<T> pubnubResult, bool logIfError = true)
27+
internal bool RegisterOperation<T>(PNResult<T> pubnubResult)
2828
{
2929
InternalStatuses.Add(pubnubResult.Status);
3030
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status: {chat.PubnubInstance.JsonPluggableLibrary.SerializeToJsonString(pubnubResult.Status)}");
3131
Error = pubnubResult.Status.Error;
3232
if (Error)
3333
{
34-
if (logIfError)
35-
{
36-
chat.Logger.Error($"Chat operation \"{OperationName}\" registered PN Status with error: {pubnubResult.Status.ErrorData.Information}");
37-
}
34+
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status with error: {pubnubResult.Status.ErrorData.Information}");
3835
Exception = pubnubResult.Status.ErrorData.Throwable;
3936
}
4037
return Error;
@@ -44,17 +41,17 @@ internal bool RegisterOperation<T>(PNResult<T> pubnubResult, bool logIfError = t
4441
/// Registers another ChatOperationResult to this ChatOperationResult.
4542
/// Returns otherChatResult.Error
4643
/// </summary>
47-
internal bool RegisterOperation(ChatOperationResult otherChatResult, bool logIfError = true)
44+
internal bool RegisterOperation(ChatOperationResult otherChatResult)
4845
{
4946
foreach (var status in otherChatResult.InternalStatuses)
5047
{
5148
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\": {chat.PubnubInstance.JsonPluggableLibrary.SerializeToJsonString(status)}");
5249
InternalStatuses.Add(status);
5350

5451
}
55-
if (otherChatResult.Error && logIfError)
52+
if (otherChatResult.Error)
5653
{
57-
chat.Logger.Error($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\" with error: {otherChatResult.Exception.Message}");
54+
chat.Logger.Debug($"Chat operation \"{OperationName}\" registered PN Status from operation \"{otherChatResult.OperationName}\" with error: {otherChatResult.Exception.Message}");
5855
}
5956
Exception = otherChatResult.Exception;
6057
Error = otherChatResult.Error;

0 commit comments

Comments
 (0)