Jump to content

Pain

Members
  • Posts

    178
  • Joined

  • Last visited

Everything posted by Pain

  1. Hello. Been programming OOP for the past year. I am very ashamed to admit that I have not learned about exceptions yet. Well actually Im not sure... Am I using them correctly? public function indexAction(Request $request) { try { if(!is_object($request)) throw new \Exception('Param msut be an object'); } catch(Exception $e) { $this->logger = $this->get('logger'); $this->logger->info("You have the following error: { $error }", array("error" => $e->getMessage())); } } I throw an exception in order for the error to appear on the screen. Then I catch the error and log it. Is this the correct usage? Or is there more? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.