Skip to content

Commit

Permalink
Add explicit error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Jul 20, 2017
1 parent 498e15b commit e3392c3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/hooks/src/createAddHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit e3392c3

Please sign in to comment.