public function postAction($id) { if (!$id) { // Normal PHP exception. throw new \Exception("No ID specified."); } $user = User::findById($id); $profile = Model\Profile::findByUser($user); if (!$user || !$profile) { throw new ModelException("No user or profile found."); } $comment = new Comment($user, $profile, "Hello!"); $comment->save(); if ($comment->getErrors()) { // Imported exception. throw new Exception("It failed."); } return $comment->getId(); }