Skip to content

Commit

Permalink
Improve error when Group middleware validation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Nov 17, 2020
1 parent a7de240 commit 4420d52
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Group.php
Expand Up @@ -112,7 +112,16 @@ private function validateMiddleware($middleware): void
return;
}

throw new InvalidArgumentException('Parameter should be either PSR middleware class name or a callable.');
if (is_scalar($middleware)) {
$type = gettype($middleware) . ' with value "' . $middleware . '"';
} elseif (is_object($middleware)) {
$type = 'an instance of ' . get_class($middleware);

} else {
$type = gettype($middleware);
}

throw new InvalidArgumentException("Parameter should be either PSR middleware class name or a callable, $type given.");
}

private function isCallable($definition): bool
Expand Down

0 comments on commit 4420d52

Please sign in to comment.