From 531b2fd6bf43b449e22dcc8a64eb792ed4abaf7b Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 9 Jul 2019 10:53:31 -0400 Subject: [PATCH] refactor: use assert.fail() instead of throwing for programmer err --- src/core/components/pin/gc-lock.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/components/pin/gc-lock.js b/src/core/components/pin/gc-lock.js index 59c64e7002..4cb255de38 100644 --- a/src/core/components/pin/gc-lock.js +++ b/src/core/components/pin/gc-lock.js @@ -1,5 +1,6 @@ 'use strict' +const assert = require('assert') const mortice = require('mortice') const pull = require('pull-stream') const pullThrough = require('pull-stream/throughs/through') @@ -32,10 +33,10 @@ class GCLock extends EventEmitter { lock (type, lockedFn, cb) { if (typeof lockedFn !== 'function') { - throw new Error(`first argument to ${type} must be a function`) + assert.fail(`first argument to GCLock.${type} must be a function`) } if (typeof cb !== 'function') { - throw new Error(`second argument to ${type} must be a callback function`) + assert.fail(`second argument to GCLock.${type} must be a callback function`) } const lockId = this.lockId++