From c1beb28b85f75c0736f933452b2666f063b8fe25 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 4 Feb 2020 18:47:25 +0100 Subject: [PATCH] Error -> TypeError --- lib/request.js | 2 +- lib/validate-profile.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/request.js b/lib/request.js index ea77c9b7..022d3d69 100644 --- a/lib/request.js +++ b/lib/request.js @@ -56,7 +56,7 @@ const request = (ctx, userAgent, reqData) => { if (profile.addChecksum || profile.addMicMac) { if (!Buffer.isBuffer(profile.salt)) { - throw new Error('profile.salt must be a Buffer.') + throw new TypeError('profile.salt must be a Buffer.') } if (profile.addChecksum) { const checksum = md5(Buffer.concat([ diff --git a/lib/validate-profile.js b/lib/validate-profile.js index 89b41b1b..248be58f 100644 --- a/lib/validate-profile.js +++ b/lib/validate-profile.js @@ -52,33 +52,33 @@ const validateProfile = (profile) => { const type = types[key] if (type === 'array') { if (!Array.isArray(profile[key])) { - throw new Error(`profile.${key} must be an array.`) + throw new TypeError(`profile.${key} must be an array.`) } } else if (type !== typeof profile[key]) { - throw new Error(`profile.${key} must be a ${type}.`) + throw new TypeError(`profile.${key} must be a ${type}.`) } if (type === 'object' && profile[key] === null) { - throw new Error(`profile.${key} must not be null.`) + throw new TypeError(`profile.${key} must not be null.`) } } if (!Array.isArray(profile.products)) { - throw new Error('profile.products must be an array.') + throw new TypeError('profile.products must be an array.') } if (profile.products.length === 0) throw new Error('profile.products is empty.') for (let product of profile.products) { if ('string' !== typeof product.id) { - throw new Error('profile.products[].id must be a string.') + throw new TypeError('profile.products[].id must be a string.') } if ('boolean' !== typeof product.default) { - throw new Error('profile.products[].default must be a boolean.') + throw new TypeError('profile.products[].default must be a boolean.') } if (!Array.isArray(product.bitmasks)) { - throw new Error(product.id + '.bitmasks must be an array.') + throw new TypeError(product.id + '.bitmasks must be an array.') } for (let bitmask of product.bitmasks) { if ('number' !== typeof bitmask) { - throw new Error(product.id + '.bitmasks[] must be a number.') + throw new TypeError(product.id + '.bitmasks[] must be a number.') } } }