@@ -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
@@ -114,7 +122,8 @@ internal open class UserManager(
114122 Logging .log(LogLevel .DEBUG , " addEmail(email: $email )" )
115123
116124 if (! OneSignalUtils .isValidEmail(email)) {
117- throw Exception (" Cannot add invalid email address as subscription: $email " )
125+ Logging .log(LogLevel .ERROR , " Cannot add invalid email address as subscription: $email " )
126+ return
118127 }
119128
120129 _subscriptionManager .addEmailSubscription(email)
@@ -124,7 +133,8 @@ internal open class UserManager(
124133 Logging .log(LogLevel .DEBUG , " removeEmail(email: $email )" )
125134
126135 if (! OneSignalUtils .isValidEmail(email)) {
127- throw Exception (" Cannot remove invalid email address as subscription: $email " )
136+ Logging .log(LogLevel .ERROR , " Cannot remove invalid email address as subscription: $email " )
137+ return
128138 }
129139
130140 _subscriptionManager .removeEmailSubscription(email)
@@ -134,7 +144,8 @@ internal open class UserManager(
134144 Logging .log(LogLevel .DEBUG , " addSms(sms: $sms )" )
135145
136146 if (! OneSignalUtils .isValidPhoneNumber(sms)) {
137- throw Exception (" Cannot add invalid sms number as subscription: $sms " )
147+ Logging .log(LogLevel .ERROR , " Cannot add invalid sms number as subscription: $sms " )
148+ return
138149 }
139150
140151 _subscriptionManager .addSmsSubscription(sms)
@@ -144,7 +155,8 @@ internal open class UserManager(
144155 Logging .log(LogLevel .DEBUG , " removeSms(sms: $sms )" )
145156
146157 if (! OneSignalUtils .isValidPhoneNumber(sms)) {
147- throw Exception (" Cannot remove invalid sms number as subscription: $sms " )
158+ Logging .log(LogLevel .ERROR , " Cannot remove invalid sms number as subscription: $sms " )
159+ return
148160 }
149161
150162 _subscriptionManager .removeSmsSubscription(sms)
@@ -154,7 +166,8 @@ internal open class UserManager(
154166 Logging .log(LogLevel .DEBUG , " setTag(key: $key , value: $value )" )
155167
156168 if (key.isEmpty()) {
157- throw Exception (" Cannot add tag with empty key" )
169+ Logging .log(LogLevel .ERROR , " Cannot add tag with empty key" )
170+ return
158171 }
159172
160173 _propertiesModel .tags[key] = value
@@ -165,7 +178,8 @@ internal open class UserManager(
165178
166179 tags.forEach {
167180 if (it.key.isEmpty()) {
168- throw Exception (" Cannot add tag with empty key" )
181+ Logging .log(LogLevel .ERROR , " Cannot add tag with empty key" )
182+ return
169183 }
170184 }
171185
@@ -178,7 +192,8 @@ internal open class UserManager(
178192 Logging .log(LogLevel .DEBUG , " removeTag(key: $key )" )
179193
180194 if (key.isEmpty()) {
181- throw Exception (" Cannot remove tag with empty key" )
195+ Logging .log(LogLevel .ERROR , " Cannot remove tag with empty key" )
196+ return
182197 }
183198
184199 _propertiesModel .tags.remove(key)
@@ -189,7 +204,8 @@ internal open class UserManager(
189204
190205 keys.forEach {
191206 if (it.isEmpty()) {
192- throw Exception (" Cannot remove tag with empty key" )
207+ Logging .log(LogLevel .ERROR , " Cannot remove tag with empty key" )
208+ return
193209 }
194210 }
195211
0 commit comments