How to catch error ?
See original GitHub issueHello,
How can I catch error (if occur)
SInfo.getItem('key', {
sharedPreferencesName: 'app',
keychainService: 'app'
}).then(value => console.log('val => ' + value))
.catch(error => console.log('err => ' + error)) // is this catch is support ?
Thanks !
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
JavaScript Errors Try Catch Throw - W3Schools
The try statement allows you to define a block of code to be tested for errors while it is being executed. The catch...
Read more >try...catch - JavaScript - MDN Web Docs - Mozilla
When an exception is thrown in the try -block, exception_var (i.e., the e in catch (e) ) holds the exception value. You can...
Read more >Error handling, "try...catch" - The Modern JavaScript Tutorial
So, try...catch can only handle errors that occur in valid code. Such errors are called “runtime errors” or, sometimes, “exceptions”.
Read more >Try/Catch in JavaScript – How to Handle Errors in JS
A try / catch block is basically used to handle errors in JavaScript. You use this when you don't want an error in...
Read more >JavaScript try...catch
Introduction to JavaScript try…catch statement · First, place the code that may cause an error in the try block. · Second, implement the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @anhhtz! It seems it is currently not supported, since we are not catching errors in the getItem method and the promise will never reject: https://github.com/mCodex/react-native-sensitive-info/blob/master/android/src/main/java/br/com/classapp/RNSensitiveInfo/RNSensitiveInfoModule.java#L120.
Do you have any example where getItem causes an error?
@afiller i think we just worked around it by putting in checks in our app state handler to make sure the data we expect from
SInfo.getItem
is actually set. if not (ie it failed/hung) we just don’t perform the ideal action. it saves us from weird behavior but doesn’t exactly fix the problem.