use typeforce >= 1.6.2 which allows us to use typeforce.TfTypeError with a custom error message.

This commit is contained in:
Ruben de Vries 2016-02-02 14:04:37 +01:00
parent ce21c99b43
commit 7c7537fc57
3 changed files with 6 additions and 5 deletions

View file

@ -2,7 +2,8 @@ var typeforce = require('typeforce')
function nBuffer (value, n) {
typeforce(types.Buffer, value)
if (value.length !== n) throw new Error('Expected ' + (n * 8) + '-bit Buffer, got ' + (value.length * 8) + '-bit Buffer')
if (value.length !== n) throw new typeforce.TfTypeError('Expected ' + (n * 8) + '-bit Buffer, got ' + (value.length * 8) + '-bit Buffer')
return true
}