From 4dba4baf9ad3c9f2b3a7d3fd63e547366b16c769 Mon Sep 17 00:00:00 2001 From: milan Date: Mon, 29 Jul 2024 20:34:34 +0530 Subject: [PATCH] Fix #46: Handle error in process authorisation request --- .../services/issue/IssueService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt index 41e307c..b1d5c33 100644 --- a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt +++ b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt @@ -203,7 +203,9 @@ class IssueService : IssueServiceInterface { "issuer_state" to (credentialOffer?.grants?.authorizationCode?.issuerState ?: "") ), ) - + if (response?.code() == 502) { + throw Exception("Unexpected error. Please try again.") + } val location: String? = if (response?.code() == 302) { if (response.headers()["Location"]?.contains("error") == true || response.headers()["Location"]?.contains("error_description") == true) { response.headers()["Location"] @@ -214,9 +216,9 @@ class IssueService : IssueServiceInterface { null } - return if(Uri.parse(location).getQueryParameter("error") != null) { + return if(location != null && Uri.parse(location).getQueryParameter("error") != null) { location - }else if (Uri.parse(location).getQueryParameter("code") != null + }else if (location != null && Uri.parse(location).getQueryParameter("code") != null || Uri.parse(location).getQueryParameter("presentation_definition") != null ) { location