Skip to content

Commit 67912a4

Browse files
committed
Don't throw for bad alias actions
1 parent 7cf7038 commit 67912a4

File tree

1 file changed

+16
-8
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal

1 file changed

+16
-8
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/UserManager.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ internal open class UserManager(
5050
Logging.log(LogLevel.DEBUG, "setAlias(label: $label, id: $id)")
5151

5252
if (label.isEmpty()) {
53-
throw Exception("Cannot add empty alias")
53+
Logging.log(LogLevel.ERROR, "Cannot add empty alias")
54+
return
5455
}
5556

5657
if (label == IdentityConstants.ONESIGNAL_ID) {
57-
throw Exception("Cannot add '${IdentityConstants.ONESIGNAL_ID}' alias")
58+
Logging.log(LogLevel.ERROR, "Cannot add '${IdentityConstants.ONESIGNAL_ID}' alias")
59+
return
5860
}
5961

6062
_identityModel[label] = id
@@ -65,11 +67,13 @@ internal open class UserManager(
6567

6668
aliases.forEach {
6769
if (it.key.isEmpty()) {
68-
throw Exception("Cannot add empty alias")
70+
Logging.log(LogLevel.ERROR, "Cannot add empty alias")
71+
return
6972
}
7073

7174
if (it.key == IdentityConstants.ONESIGNAL_ID) {
72-
throw Exception("Cannot add '${IdentityConstants.ONESIGNAL_ID}' alias")
75+
Logging.log(LogLevel.ERROR, "Cannot add '${IdentityConstants.ONESIGNAL_ID}' alias")
76+
return
7377
}
7478
}
7579

@@ -82,11 +86,13 @@ internal open class UserManager(
8286
Logging.log(LogLevel.DEBUG, "removeAlias(label: $label)")
8387

8488
if (label.isEmpty()) {
85-
throw Exception("Cannot remove empty alias")
89+
Logging.log(LogLevel.ERROR, "Cannot remove empty alias")
90+
return
8691
}
8792

8893
if (label == IdentityConstants.ONESIGNAL_ID) {
89-
throw Exception("Cannot remove '${IdentityConstants.ONESIGNAL_ID}' alias")
94+
Logging.log(LogLevel.ERROR, "Cannot remove '${IdentityConstants.ONESIGNAL_ID}' alias")
95+
return
9096
}
9197

9298
_identityModel.remove(label)
@@ -97,11 +103,13 @@ internal open class UserManager(
97103

98104
labels.forEach {
99105
if (it.isEmpty()) {
100-
throw Exception("Cannot remove empty alias")
106+
Logging.log(LogLevel.ERROR, "Cannot remove empty alias")
107+
return
101108
}
102109

103110
if (it == IdentityConstants.ONESIGNAL_ID) {
104-
throw Exception("Cannot remove '${IdentityConstants.ONESIGNAL_ID}' alias")
111+
Logging.log(LogLevel.ERROR, "Cannot remove '${IdentityConstants.ONESIGNAL_ID}' alias")
112+
return
105113
}
106114
}
107115

0 commit comments

Comments
 (0)