Logger::logException PHP Method

logException() public method

public logException ( $e )
    public function logException($e)
    {
        // logs exception from the catch statement
        // contains code from Logger::caughtException(), as this code won't launch
        // if exception is caught
        $frame = $e->my_backtrace[$e->shift - 1];
        $this->logLine($this->txtLine(get_class($e) . ': (' . $e->getCode() . ') ' . $e->getMessage(), $frame), 2, 'error');
        return $this;
    }

Usage Example

Example #1
0
 public function persist($entity)
 {
     try {
         if ($entity->isNew()) {
             $id = $this->db->insertEntity($this->table, $entity);
             if ($id == 0) {
                 throw new RepoException("Failed to persist entity.");
             }
         } else {
             $id = $entity->getId();
             if (!$this->db->updateEntity($this->table, $entity)) {
                 throw new RepoException("Failed to persist entity.");
             }
         }
         return $this->find($id);
     } catch (\Exception $e) {
         $this->logger->logException($e);
         return false;
     }
 }
All Usage Examples Of Logger::logException