From e3392c3d65916d3379c09ba976451edcfc7d84d9 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Thu, 20 Jul 2017 19:09:58 +0200 Subject: [PATCH] Add explicit error reporting --- packages/hooks/src/createAddHook.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/hooks/src/createAddHook.js b/packages/hooks/src/createAddHook.js index 298b112..f172e84 100644 --- a/packages/hooks/src/createAddHook.js +++ b/packages/hooks/src/createAddHook.js @@ -16,7 +16,13 @@ function createAddHook( hooks ) { * @param {?number} priority Priority of this hook (default=10) */ return function addHook( hookName, callback, priority ) { - if ( typeof hookName !== 'string' || typeof callback !== 'function' ) { + if ( typeof hookName !== 'string' ) { + console.error( 'The hook name must be a string.' ); + return; + } + + if ( typeof callback !== 'function' ) { + console.error( 'The hook callback must be a function.' ); return; } @@ -29,6 +35,7 @@ function createAddHook( hooks ) { // Validate numeric priority if ( isNaN( priority ) ) { + console.error( 'The hook priority must be omitted or a number.' ); return; }