question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to catch error ?

See original GitHub issue

Hello,

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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
vspedrcommented, Aug 27, 2018

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?

1reaction
jpodprocommented, Jan 26, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found