Catch uncaught exceptions to prevent crash (#134)

`NullPointerException` thrown on some Huawei devices is crashing entire app.
Handle all exceptions and rethrow them as caught exceptions.

This is an attempt to prevent issue described in https://github.com/oblador/react-native-keychain/issues/115.
This commit is contained in:
maxkomarychev 2018-07-20 11:07:07 +03:00 committed by Joel Arvidsson
parent e311144745
commit fca9c8ad2f
1 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,8 @@ public class CipherStorageKeystoreAESCBC implements CipherStorage {
throw new CryptoFailedException("Could not encrypt data for service " + service, e);
} catch (KeyStoreException | KeyStoreAccessException e) {
throw new CryptoFailedException("Could not access Keystore for service " + service, e);
} catch (Exception e) {
throw new CryptoFailedException("Unknown error: " + e.getMessage(), e);
}
}
@ -108,6 +110,8 @@ public class CipherStorageKeystoreAESCBC implements CipherStorage {
throw new CryptoFailedException("Could not get key from Keystore", e);
} catch (KeyStoreAccessException e) {
throw new CryptoFailedException("Could not access Keystore", e);
} catch (Exception e) {
throw new CryptoFailedException("Unknown error: " + e.getMessage(), e);
}
}
@ -123,6 +127,8 @@ public class CipherStorageKeystoreAESCBC implements CipherStorage {
}
} catch (KeyStoreException e) {
throw new KeyStoreAccessException("Failed to access Keystore", e);
} catch (Exception e) {
throw new KeyStoreAccessException("Unknown error " + e.getMessage(), e);
}
}