Skip to content

Commit

Permalink
Updated links (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmariuzzo authored and benjamingr committed Jul 13, 2017
1 parent 3d2e57f commit 4f90934
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/docs/warning-explanations.md
Expand Up @@ -5,13 +5,13 @@ title: Warning Explanations

[warning-explanations](unfinished-article)

- [Warning: .then() only accepts functions](#warning-.then)
- [Warning: .then() only accepts functions](#warning-then-only-accepts-functions)
- [Warning: a promise was rejected with a non-error](#warning-a-promise-was-rejected-with-a-non-error)
- [Warning: a promise was created in a handler but was not returned from it](#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it)

Note - in order to get full stack traces with warnings in Node 6.x+ you need to enable to `--trace-warnings` flag which will give you a full stack trace of where the warning is coming from.

##Warning: .then() only accepts functions
## Warning: .then() only accepts functions

If you see this warning your code is probably not doing what you expect it to, the most common reason is passing the *result* of calling a function to [.then()](.) instead of the function *itself*:

Expand All @@ -33,7 +33,7 @@ getImage().then(processImage)

*If you are wondering why this is a warning and not a simple TypeError it is because the due to historic reasons Promises/A+ specification requires that incorrect usage is silently ignored.*

##Warning: a promise was rejected with a non-error
## Warning: a promise was rejected with a non-error

Due to a historic mistake in JavaScript, the `throw` statement is allowed to be used with any value, not just errors, and Promises/A+ choosing to inherit this mistake, it is possible to reject a promise with a value that is not an error.

Expand All @@ -44,7 +44,7 @@ Since all objects support having properties you might still wonder why exactly d
You should heed this warning because rejecting a promise with a non-error makes debugging extremely hard and costly. Additionally, if you reject with simple primitives such as `undefined` (commonly caused by simply calling `reject()`) you cannot handle errors at all because it's impossible to tell from `undefined` what exactly went wrong. All you can tell the user is that "something went wrong" and lose them forever.


##Warning: a promise was created in a handler but was not returned from it
## Warning: a promise was created in a handler but was not returned from it

This usually means that you simply forgot a `return` statement somewhere, which will cause a runaway promise that is not connected to any promise chain.

Expand Down

0 comments on commit 4f90934

Please sign in to comment.