From 697e18dd2b1ec3ec7c280581f96fd7ba84341535 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 8 Oct 2015 13:56:41 +0200 Subject: [PATCH] v2.0.1: Map unknown errors to scrypt.InternalError correctly --- lib/scrypt-for-humans.coffee | 2 +- lib/scrypt-for-humans.js | 3 ++- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/scrypt-for-humans.coffee b/lib/scrypt-for-humans.coffee index 1289b2d..b8d201e 100644 --- a/lib/scrypt-for-humans.coffee +++ b/lib/scrypt-for-humans.coffee @@ -44,7 +44,7 @@ scryptHandler = (resolve, reject) -> # Well, `scrypt` now returns real Error objects. Except now they don't have error codes anymore... return (err, result) -> if err? - errorObj = switch scryptErrorMap[err.message] + errorObj = switch (scryptErrorMap[err.message] ? -1) when 1, 2, 3, 4, 5, 6, 9, 10, 12, 13, -1 then errors.ScryptInternalError when 7, 8 then errors.ScryptInputError when 11 then errors.ScryptPasswordError diff --git a/lib/scrypt-for-humans.js b/lib/scrypt-for-humans.js index 662a370..4bace34 100644 --- a/lib/scrypt-for-humans.js +++ b/lib/scrypt-for-humans.js @@ -65,7 +65,8 @@ scryptHandler = function(resolve, reject) { var errorObj; if (err != null) { errorObj = (function() { - switch (scryptErrorMap[err.message]) { + var _ref; + switch ((_ref = scryptErrorMap[err.message]) != null ? _ref : -1) { case 1: case 2: case 3: diff --git a/package.json b/package.json index 1c05bed..7938d55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scrypt-for-humans", - "version": "2.0.0", + "version": "2.0.1", "description": "A human-friendly API wrapper for the Node.js Scrypt bindings.", "main": "index.js", "scripts": {