public static function singleton() { if (self::$instancia == null) { self::$instancia = new self(); } return self::$instancia; }
public function send() { parent::Send(); if ($this->IsError()) { ErrorLogger::add('email', 'Email sending failed', $this->ErrorInfo); return false; } return true; }
/** * Delete node * * @param integer $leftKey * @param integer $rightKey * @param array $filter * @param boolean $useTransaction * @return boolean|string */ public function deleteNode($leftKey, $rightKey, array $filter = [], $useTransaction = true) { try { if ($useTransaction) { $this->tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction(); } $predicate = new Predicate(); $this->tableGateway->delete([$predicate->greaterThanOrEqualTo($this->left, $leftKey), $predicate->lessThanOrEqualTo($this->right, $rightKey)] + $filter); $predicate = new Predicate(); $this->tableGateway->update([$this->left => new Expression('IF(' . $this->left . ' > ?, ' . $this->left . ' - (? - ? + 1), ' . $this->left . ')', [$leftKey, $rightKey, $leftKey]), $this->right => new Expression($this->right . ' - (? - ? + 1)', [$rightKey, $leftKey])], [$predicate->greaterThan($this->right, $rightKey)] + $filter); if ($useTransaction) { $this->tableGateway->getAdapter()->getDriver()->getConnection()->commit(); } } catch (Exception $e) { if ($useTransaction) { $this->tableGateway->getAdapter()->getDriver()->getConnection()->rollback(); } ErrorLogger::log($e); return $e->getMessage(); } return true; }
public static function exception_handler($exception) { if (isset($exception->xdebug_message)) { $error_string = '<pre>' . $exception->xdebug_message . '</pre>'; } else { $error_string = "<b>Uncaught exception:</b> " . $exception->getMessage() . "<br/>Trace path:<br/>"; foreach ($exception->getTrace() as $arr_error) { $file = '`Can`t detect file`'; if (isset($arr_error['file'])) { $file = $arr_error['file']; } $line = '`Can`t detect line`'; if (isset($arr_error['line'])) { $line = $arr_error['line']; } $class = '`Can`t detect class`'; if (isset($arr_error['class'])) { $class = $arr_error['class']; } $function = '`Can`t detect function`'; if (isset($arr_error['function'])) { $function = $arr_error['function']; } $error_string .= "<b>" . $file . "</b>, method <b>" . $function . "</b> of class <b>" . $class . "</b>, line <b>" . $line . "</b><br/>"; } } echo $error_string; ErrorLogger::send_email('Error report', $error_string, '', 'ERS_ERROR_TYPE_ERROR'); exit; }
public function imprError($err) { try { if (!class_exists('ErrorLogger')) { throw new Exception("clase ErrorLogger no existe"); } else { $this->_logger = ErrorLogger::singleton(); if ($err == "") { throw new Exception("Error está vacio"); } else { $this->_logger->imprError($err); } } } catch (Exception $e) { switch ($e->getMessage()) { case "clase ErrorLogger no existe": //no hagas nada, no hay handler de errores // echo "no hay clase"; break; case "Error está vacio": //no hagas nada, no hay handler error $this->_logger->imprError("Error está vacio"); break; } } }
private function __construct() { ExceptionLogger::initialize(); ErrorLogger::initialize(); }