|
|
|
|
|
by esailija
4437 days ago
|
|
It does work for any library that uses callbacks - a node library that uses callbacks but not the node js callback convention has a bug. 1) There is not much work in promisifying libraries, for example the entire redis
library can be promisified using 2 lines: var Promise = require("bluebird");
var redis = require("redis");
Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);
After those lines all redis client objects have promise-returning versions of the methods. E.g. `redisClient.getAsync()` is the promise-returning version of `redisClient.get()`2) Mixing callbacks and promises will result in very ugly code, see 1) to avoid it. 3) Forget about .fail(), this is not how promise error handling works. Use `.catch()` like you would use
try catch. In your case that means not using it at all - then a full stack trace is automatically logged. Try catch is meant to be used with expected errors like file not existing, not bugs. |
|