else statement returns still emits a return a value error
See original GitHub issueThe error each then() should return a value
is reported even though the .then
always returns a promise in the code below.
Apparently the logic for following return values can’t evaluate an else clause
return oracle.getPrices(c)
.then(function(p) {
if (p.price != 0) {
return p.price.toNumber() / 1e6;
} else {
// XXX unavoidable race
return 200;
}
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to correct a #VALUE! error in the IF function
If a function's syntax is not constructed correctly, it can return the #VALUE! error. Solution: Make sure you are constructing the syntax properly....
Read more >How to fix inconsistent return statement in python?
I am new to python and i have this project I am working on a small project with two functions where the first...
Read more >if / else errors - learn how to fix these - Codecademy
In the particular code example above, if the program execution has reached the else statement it means that: a < b returned false...
Read more >RxJs Error Handling: Complete Practical Guide
As we can see, this HTTP stream emits only one value, and then it completes, which means that no errors occurred.
Read more >Exceptions and Error Handling, C++ FAQ - Standard C++
The commonly used alternative to try / catch / throw is to return a return code (sometimes called an error code) that 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
right because I personally prefer the
no-else-return
rule, so in my case I’d still do thereturn 200
at the root level of the function.Yeah totally valid bug though, solution is tricky to enforce properly.
We could check that there’s any
return
inside of athen
function. For example:But then it obviously misses cases like this where the root of the function isn’t covered, but to some extent that is covered by
consistent-return
.What do you think? Would you be able to try to make the code change?
ahh thanks for the note @scottnonnenberg I’ll try to look at this…in the meantime you may be abe to do something like this: