title: Should a class be able to catch an exception from a class that it doesn't know about?
body: <p>I wrote some code in an MVC Framework that looks something like:</p>
  
  <pre><code>class Controller_Test extends Controller
  {
     public function action_index()
     {
        $obj = new MyObject();
        $errors = array();
  
        try
        {
           $results = $obj-&gt;doSomething();
        }
        catch(MyObject_Exception $e)
        {
           $e-&gt;getErrors();
        }
        catch(Exception $e)
        {
           $errors[] = $e-&gt;getMessage();
        }
  }
  </code></pre>
  
  <p>My friend argues that the Controller should know nothing about MyObject, and therefore I should not catch MyObject_Exception.</p>
  
  <p>He argues that the code should do something like this instead:</p>
  
  <pre><code>class Controller_Test extends Controller
  {
     public function action_index()
     {
        $obj = new MyObject();
        $errors = array();
  
        if($obj-&gt;doSomething())
        {
           $results = $obj-&gt;getResults();
        }
        else
        {
           $errors = $obj-&gt;getErrors();
        }
  }
  </code></pre>
  
  <p>I definitely understand his approach, but feel as though state management can lead to unintended side effects. </p>
  
  <p>What is the right or preferred approach? </p>
  
  <p>Edit: mistakenly put $obj->getErrors() in MyObject_Exception catch clause instead of $e->getErrors();</p>