diff --git a/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryImpl.kt index 6b4300499..92b2d07e8 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryImpl.kt @@ -200,7 +200,7 @@ class GeneratorRepositoryImpl( GeneratedForwardedServiceUsernameResult.Success(generatedEmail) }, onFailure = { - GeneratedForwardedServiceUsernameResult.InvalidRequest + GeneratedForwardedServiceUsernameResult.InvalidRequest(it.message) }, ) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/model/GeneratedForwardedServiceUsernameResult.kt b/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/model/GeneratedForwardedServiceUsernameResult.kt index d0f3e6d39..46a67f87d 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/model/GeneratedForwardedServiceUsernameResult.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/tools/generator/repository/model/GeneratedForwardedServiceUsernameResult.kt @@ -14,5 +14,5 @@ sealed class GeneratedForwardedServiceUsernameResult { /** * There was an error during the operation. */ - data object InvalidRequest : GeneratedForwardedServiceUsernameResult() + data class InvalidRequest(val message: String?) : GeneratedForwardedServiceUsernameResult() } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt index 9ccf6f94a..ead2d0b7e 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorViewModel.kt @@ -651,8 +651,13 @@ class GeneratorViewModel @Inject constructor( } } - GeneratedForwardedServiceUsernameResult.InvalidRequest -> { - sendEvent(GeneratorEvent.ShowSnackbar(R.string.an_error_has_occurred.asText())) + is GeneratedForwardedServiceUsernameResult.InvalidRequest -> { + sendEvent( + GeneratorEvent.ShowSnackbar( + message = result.message?.asText() + ?: R.string.an_error_has_occurred.asText(), + ), + ) } } } diff --git a/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryTest.kt index 759528742..ddb577459 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/repository/GeneratorRepositoryTest.kt @@ -410,7 +410,10 @@ class GeneratorRepositoryTest { val result = repository.generateForwardedServiceUsername(request) - assertEquals(GeneratedForwardedServiceUsernameResult.InvalidRequest, result) + assertEquals( + GeneratedForwardedServiceUsernameResult.InvalidRequest(exception.message), + result, + ) coVerify { generatorSdkSource.generateForwardedServiceEmail(request) } }