Skip to content

Commit c04ee80

Browse files
committed
more readable exception messages
1 parent 21b2a8b commit c04ee80

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ComponentModel/Container.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function addComponent(IComponent $component, $name, $insertBefore = NULL)
4747
$name = (string) $name;
4848

4949
} elseif (!is_string($name)) {
50-
throw new Nette\InvalidArgumentException("Component name must be integer or string, " . gettype($name) . " given.");
50+
throw new Nette\InvalidArgumentException(sprintf('Component name must be integer or string, %s given.', gettype($name)));
5151

5252
} elseif (!preg_match('#^[a-zA-Z0-9_]+\z#', $name)) {
5353
throw new Nette\InvalidArgumentException("Component name must be non-empty alphanumeric string, '$name' given.");
@@ -120,7 +120,7 @@ public function getComponent($name, $need = TRUE)
120120
$name = (string) $name;
121121

122122
} elseif (!is_string($name)) {
123-
throw new Nette\InvalidArgumentException("Component name must be integer or string, " . gettype($name) . " given.");
123+
throw new Nette\InvalidArgumentException(sprintf('Component name must be integer or string, %s given.', gettype($name)));
124124

125125
} else {
126126
$a = strpos($name, self::NAME_SEPARATOR);
@@ -131,7 +131,7 @@ public function getComponent($name, $need = TRUE)
131131

132132
if ($name === '') {
133133
if ($need) {
134-
throw new Nette\InvalidArgumentException("Component or subcomponent name must not be empty string.");
134+
throw new Nette\InvalidArgumentException('Component or subcomponent name must not be empty string.');
135135
}
136136
return;
137137
}

0 commit comments

Comments
 (0)