Skip to content

Commit

Permalink
Throw errors instead of using Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Nov 1, 2015
1 parent e12ee61 commit 34914f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
"homepage": "https://github.com/blakeembrey/popsicle-status",
"devDependencies": {
"chai": "^3.3.0",
"es6-promise": "^3.0.2",
"istanbul": "^0.3.5",
"mocha": "^2.0.1",
"nock": "^2.13.0",
"popsicle": "^1.1.1",
"popsicle": "^1.2.1",
"pre-commit": "^1.0.6",
"standard": "^5.3.1"
}
Expand Down
8 changes: 4 additions & 4 deletions popsicle-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function popsicleStatus () {
return function (req) {
req.after(function (res) {
if (res.status >= lower && res.status <= upper) {
return Promise.resolve(res)
return res
}

var message
Expand All @@ -28,9 +28,9 @@ function popsicleStatus () {
message = 'should be between ' + lower + ' and ' + upper
}

var err = res.error('Invalid HTTP status, ' + res.status + ', ' + message, 'EINVALIDSTATUS')
err.status = res.status
return Promise.reject(err)
var error = res.error('Invalid HTTP status, ' + res.status + ', ' + message, 'EINVALIDSTATUS')
error.status = res.status
throw error
})
}
}

0 comments on commit 34914f0

Please sign in to comment.