Last active
December 10, 2015 02:38
-
-
Save thejhh/4369095 to your computer and use it in GitHub Desktop.
Promise test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "promise-test", | |
| "version": "0.0.1", | |
| "description": "Promise test", | |
| "main": "test.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "repository": "", | |
| "author": "Jaakko-Heikki Heusala <jheusala@iki.fi>", | |
| "license": "MIT", | |
| "dependencies": { | |
| "q": "*" | |
| }, | |
| "private": true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Q = require('q'); | |
| Q.fcall(function() { | |
| throw new Error("Hello"); | |
| }).then(function() { | |
| console.log('1st resolved'); | |
| }, function(err) { | |
| console.error('ERROR: 1st:', err); | |
| }).then(function() { | |
| console.log('2nd resolved'); | |
| }, function(err) { | |
| console.error('ERROR: 2nd:', err); | |
| }).done(); | |
| // $ node test.js | |
| // ERROR: 1st: [Error: Hello] | |
| // 2nd resolved | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment