,
, TypeError(), , .
Joyent | :
, . . , - [...]
. , . ( ).
, , , Error() TypeError().
?
, , SDK AWS. , , , , , , - , , , API, ?
, , . , , . - , API undefined, .
?
(, , , , badInput), , :
try {
if (badInput) {
throw new Error('failed')
}
...
} catch (error) {
}
:
process.on('uncaughtException', function (error) {
})
if (badInput) {
throw new Error('failed')
}
try {
...
} catch (error) {
}
Node.js, , , :
Example func | Kind of func | Example error | Kind of error | How to | Caller uses
| | | | deliver |
==========================================================================================
fs.stat | asynchronous | file not found | operational | callback | handle callback
| | | | | error
-------------+--------------+----------------+---------------+----------+-----------------
fs.stat | asynchronous | null for | programmer | throw | none (crash)
| | filename | | |
, , , , , -, .
TL; DR
A function that must return a Promiseunder operating conditions must throwsynchronously when an error is caused by an error, and must rejectasynchronously when an error occurs in a correctly written program.
This reflects the official Joyent recommendation :
The best way to repair programmer errors is to work immediately.