Example #1
0
 /**
  * Constructor
  * 
  * Logs all info to server log
  * 
  * @param string $msg_code message code to be used to present error
  * @param mixed $internal_details details to log
  * @param mixed $public_details details to give to the user (logged as well)
  */
 public function __construct($msg_code, $internal_details = null, $public_details = null)
 {
     $this->uid = uniqid();
     // Build data
     $this->details = $public_details;
     if (!$internal_details) {
         $internal_details = array();
     }
     if (!is_array($internal_details)) {
         $internal_details = array($internal_details);
     }
     if ($public_details) {
         if (!is_array($public_details)) {
             $public_details = array($public_details);
         }
         $internal_details = array_merge($public_details, $internal_details);
     }
     $log = array('exception' => $msg_code, 'trace' => explode("\n", $this->getTraceAsString()), 'details' => array());
     // Cast to string(s)
     foreach ($internal_details as $key => $detail) {
         $key = is_int($key) ? '' : $key . ' = ';
         if (is_scalar($detail)) {
             $log['details'][] = $key . $detail;
         } else {
             foreach (explode("\n", print_r($detail, true)) as $line) {
                 $log['details'][] = $key . $line;
             }
         }
     }
     parent::__construct($msg_code, $log);
 }
 /**
  * Constructor
  * 
  * @param string $id template id
  */
 public function __construct($id)
 {
     parent::__construct('template_not_found', 'id = ' . $id);
 }