OOP (course 4): Static methods, Namespaces, Exceptions & Traits! Woh!
Different Exception Classes
Start your All-Access Pass to unlock this challenge
Buy Access Login

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?

Select your answer
Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.