Start your All-Access Pass to unlock this challenge
Challenge 1 / 1
We've improved the PlanetRenderer
to throw an exception if
a planet has no hex color. Rejoice!
// ...
class PlanetRenderer
{
public function render(PlanetInterface $planet)
{
if ($planet->getRadius() < 0) {
throw new \Exception('Invalid radius!');
}
if (!$planet->getHexColor()) {
throw new \Exception('Missing hex color');
}
}
}
Can you use a try-catch
block to only catch the
"Invalid radius!" exception?
Skip challenges and go to theNext Chapter