Skip to content

Commit

Permalink
Show vault format in error message if it is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Mar 16, 2022
1 parent 0fc53f9 commit c19e771
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.cryptomator.presentation.exception
import android.content.ActivityNotFoundException
import android.content.Context
import org.cryptomator.cryptolib.api.InvalidPassphraseException
import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException
import org.cryptomator.domain.di.PerView
import org.cryptomator.domain.exception.CloudAlreadyExistsException
import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException
Expand Down Expand Up @@ -54,7 +53,6 @@ class ExceptionHandlers @Inject constructor(private val context: Context, defaul
staticHandler(HashMismatchUpdateCheckException::class.java, R.string.error_hash_mismatch_update)
staticHandler(GeneralUpdateErrorException::class.java, R.string.error_general_update)
staticHandler(SSLHandshakePreAndroid5UpdateCheckException::class.java, R.string.error_general_update)
staticHandler(UnsupportedVaultFormatException::class.java, R.string.error_vault_version_not_supported)
staticHandler(
MissingVaultConfigFileException::class.java, String.format(
ResourceHelper.getString(R.string.error_vault_config_file_missing_due_to_format_999),
Expand Down Expand Up @@ -82,6 +80,7 @@ class ExceptionHandlers @Inject constructor(private val context: Context, defaul
exceptionHandlers.add(CancellationExceptionHandler())
exceptionHandlers.add(NoSuchVaultExceptionHandler())
exceptionHandlers.add(PermissionNotGrantedExceptionHandler())
exceptionHandlers.add(UnsupportedVaultFormatExceptionHandler())
}

fun handle(view: View, e: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cryptomator.presentation.exception

import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException
import org.cryptomator.presentation.R
import org.cryptomator.presentation.ui.activity.view.View
import org.cryptomator.presentation.util.ResourceHelper.Companion.getString
import org.cryptomator.util.ExceptionUtil

class UnsupportedVaultFormatExceptionHandler : ExceptionHandler() {

override fun supports(e: Throwable): Boolean {
return ExceptionUtil.contains(e, UnsupportedVaultFormatException::class.java)
}

override fun doHandle(view: View, e: Throwable) {
val detectedFormat = ExceptionUtil.extract(e, UnsupportedVaultFormatException::class.java).get().detectedVersion
view.showError(String.format(getString(R.string.error_vault_version_not_supported), detectedFormat))
}
}
2 changes: 1 addition & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<string name="error_no_network_connection">No network connection</string>
<string name="error_invalid_passphrase">Wrong password</string>
<string name="error_file_or_folder_exists">A file or folder already exists.</string>
<string name="error_vault_version_not_supported">Unsupported vault. This vault has been created with another version of Cryptomator.</string>
<string name="error_vault_version_not_supported">Vault version %1$s is unsupported. This vault has been created with an older or newer version of Cryptomator.</string>
<string name="error_vault_config_file_missing_due_to_format_999">%1$s file is missing in your vault folder. Make sure that this file exists in your vault folder in the cloud.</string>
<string name="error_vault_already_exists">Vault already exists.</string>
<string name="error_no_such_file">File does not exist.</string>
Expand Down

0 comments on commit c19e771

Please sign in to comment.