@@ -107,28 +107,24 @@ internal class TokenMigrationActivity : ComponentActivity() {
107107
108108 // TODO: Move to non-deprecated getParcelableExtra when min API >= 33
109109 val oAuthConfig = intent.getParcelableExtra<OAuthConfig >(EXTRA_OAUTH_CONFIG ) ? : run {
110- resultCallback.onMigrationError(" Unable to parse OAuthConfig." , null , null )
111- finish()
110+ logMigrationError(resultCallback, " Unable to parse OAuthConfig." , null , null )
112111 return
113112 }
114113
115114 val orgId = intent.getStringExtra(EXTRA_ORG_ID )
116115 val userId = intent.getStringExtra(EXTRA_USER_ID )
117116 if ( orgId == null || userId == null ) {
118- resultCallback.onMigrationError(" Unable to parse OAuthConfig." , null , null )
119- finish()
117+ logMigrationError(resultCallback, " Unable to parse OAuthConfig." , null , null )
120118 return
121119 }
122120 val user = UserAccountManager .getInstance().getUserFromOrgAndUserId(orgId, userId) ? : run {
123- resultCallback.onMigrationError(" Unable to build user account." , null , null )
124- finish()
121+ logMigrationError(resultCallback, " Unable to build user account." , null , null )
125122 return
126123 }
127124 val client = runCatching {
128125 SalesforceSDKManager .getInstance().clientManager.peekRestClient(user)
129126 }.getOrElse { e ->
130- resultCallback.onMigrationError(" Unable to build RestClient." , null , e as ? Exception )
131- finish()
127+ logMigrationError(resultCallback, " Unable to build RestClient." , null , e as ? Exception )
132128 return
133129 }
134130
@@ -152,12 +148,12 @@ internal class TokenMigrationActivity : ComponentActivity() {
152148 }
153149 }.getOrNull()
154150 } ? : run {
155- resultCallback.onMigrationError(
156- /* error = */ " Request for single access bridge url failed." ,
157- /* errorDesc = */ " User's existing token may be invalid." ,
158- /* e = */ null ,
151+ logMigrationError(
152+ resultCallback = resultCallback,
153+ error = " Request for single access bridge url failed" ,
154+ errorDesc = " User's existing token may be invalid." ,
155+ e = null ,
159156 )
160- finish()
161157 return @launch
162158 }
163159 viewModel.dynamicBackgroundColor.value = Color .Transparent .copy(alpha = HALF_ALPHA )
@@ -231,12 +227,12 @@ internal class TokenMigrationActivity : ComponentActivity() {
231227 // Did we fail?
232228 when {
233229 error != null -> {
234- resultCallback.onMigrationError(
235- error,
236- params[" error_description" ],
237- null ,
230+ logMigrationError(
231+ resultCallback = resultCallback,
232+ error = error,
233+ errorDesc = params[" error_description" ],
234+ e = null ,
238235 )
239- finish()
240236 }
241237
242238 else -> {
@@ -248,7 +244,7 @@ internal class TokenMigrationActivity : ComponentActivity() {
248244 when {
249245 viewModel.useWebServerFlow ->
250246 viewModel.onWebServerFlowComplete(
251- params[" code" ],
247+ code = params[" code" ],
252248 onAuthFlowError = resultCallback.onMigrationError,
253249 onAuthFlowSuccess = resultCallback.onMigrationSuccess,
254250 loginServer = instanceServer,
@@ -257,7 +253,7 @@ internal class TokenMigrationActivity : ComponentActivity() {
257253
258254 else ->
259255 viewModel.onAuthFlowComplete(
260- TokenEndpointResponse (params),
256+ tr = TokenEndpointResponse (params),
261257 onAuthFlowError = resultCallback.onMigrationError,
262258 onAuthFlowSuccess = resultCallback.onMigrationSuccess,
263259 tokenMigration = true ,
@@ -300,6 +296,18 @@ internal class TokenMigrationActivity : ComponentActivity() {
300296 loadUrl(frontDoorUrl)
301297 }
302298
299+ private fun logMigrationError (
300+ resultCallback : MigrationCallbackRegistry .MigrationCallbacks ,
301+ error : String ,
302+ errorDesc : String? ,
303+ e : Throwable ? ,
304+ ) {
305+ val message = error + (errorDesc?.let { " : $it " } ? : " " )
306+ SalesforceSDKLogger .e(TAG , message, e)
307+ resultCallback.onMigrationError(error, errorDesc, e)
308+ finish()
309+ }
310+
303311 // Ensure Status Bar Icons are readable no matter which OS theme is used.
304312 private fun makeStatusBarVisible () {
305313 val usingDarkTheme = viewModel.dynamicBackgroundTheme.value == DARK
0 commit comments