Log an Exception

Hey,

is there a way to throw an exception and log it without the program dying?

throw new Exception('message about something');

without the try/catch?

Do I have to extend exception?

class Err extends Exception
{
   // What do i do here? is there a function that dumps out the trace?
  // function errormessage()
  // { //my code to log the error //
  
}

You’d have to do it in the construct I think:

class Err extends Exception
{
   public function __construct($message, $code = 0)
   {
      parent::__construct($message, $code);

      // Get trace (or get as string: $this->getTraceAsString())
      $trace = $this->getTrace();

      // Do log here
   }
}