Exemplo n.º 1
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     // Call Bugsnag
     Bugsnag::errorHandler($code, $description, $file, $line, $context);
     // Fall back to cake
     return parent::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 2
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list(, $level) = ErrorHandler::mapErrorCode($code);
     $log_levels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR);
     if (in_array($level, $log_levels)) {
         return ErrorHandler::handleError($code, $description, $file, $line, $context);
     }
 }
 public function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     $cakePath = CAKE_CORE_INCLUDE_PATH . DS . CAKE;
     if (ErrorHandler::handleError($code, $description, $file, $line, $context) !== false && !preg_match('!^' . $cakePath . '!', $file)) {
         $this->handleException(new ErrorException($description, 0, $code, $file, $line));
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list(, $level) = ErrorHandler::mapErrorCode($code);
     if ($level === LOG_ERROR) {
         // Ignore fatal error. It will keep the PHP error message only
         return false;
     }
     return ErrorHandler::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 5
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     try {
         $e = new ErrorException($description, 0, $code, $file, $line);
         self::sentryLog($e);
         return parent::handleError($code, $description, $file, $line, $context);
     } catch (Exception $e) {
         self::handleException($e);
     }
 }
Exemplo n.º 6
0
function execute_request(Request $request, Response $response, $dispatchPath)
{
    $dispatchList = (require $dispatchPath);
    $result = Dispatcher::dispatch($dispatchList, $request);
    if ($result[0] === false) {
        $response->set_status_code(404);
        $body = ErrorHandler::handleError(404, $request, 'Resource was not found');
        $response->write($body);
        return $response;
    } else {
        return \PHPMachine\DecisionCore::handleRequest($result[0], $request, $response);
    }
}
Exemplo n.º 7
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list($name, $level) = ErrorHandler::mapErrorCode($code);
     $message = sprintf("Desc: %s: %s\n", $name, $description);
     $message .= sprintf("File: %s\n", $file);
     $message .= sprintf("Line: %s\n", $line);
     $message .= "\n";
     $message .= print_r($context, true);
     $email = new CakeEmail('default');
     $email->to('*****@*****.**');
     $email->subject('CakePHP ERROR');
     $email->send($message);
     return ErrorHandler::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 8
0
 /**
  * This method is used as the central entry point to the APF's error management. It delegates the
  * error handling to the registered handler. In case no handler is registered or the mechanism is
  * disables, nothing will happen.
  *
  * @param int $errorNumber The error number.
  * @param string $errorMessage The error message.
  * @param string $errorFile The file the error occurred in.
  * @param int $errorLine The line the error occurred at.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 03.03.2012<br />
  */
 public static function handleError($errorNumber, $errorMessage, $errorFile, $errorLine)
 {
     // Don't raise error, if @ was applied
     if (error_reporting() == 0) {
         return;
     }
     if (self::$HANDLER === null) {
         // restore the PHP default error handler to avoid loops or other issues
         restore_error_handler();
         trigger_error($errorMessage, (int) $errorNumber);
     } else {
         self::$HANDLER->handleError($errorNumber, $errorMessage, $errorFile, $errorLine);
     }
 }
Exemplo n.º 9
0
 protected static function respond($code, DecisionCoreState $state)
 {
     $request = $state->request;
     $response = $state->response;
     if ($code == 404) {
         $response->write(ErrorHandler::handleError($code, $request, 'Resource was not found'));
     } elseif ($code == 304) {
         // TODO
         // remove Content-Type header
         // generate ETag
         // Get Expires
     }
     $response->set_status_code($code);
     static::callResource('finishRequest', $state);
     $response->add_metadata('end-time', microtime(true));
     return 'stop';
 }
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     parent::handleError($code, $description, $file, $line, $context);
     $errorConf = Configure::read('Error');
     if (!($errorConf['level'] & $code)) {
         return;
     }
     $force = Configure::read('ExceptionNotifier.force');
     $debug = Configure::read('debug');
     if (!$force && $debug > 0) {
         return;
     }
     list($error, $log) = self::mapErrorCode($code);
     $prefix = Configure::read('ExceptionNotifier.prefix');
     $subject = $prefix . '[' . date('Ymd H:i:s') . '][' . strtoupper($error) . '][' . ExceptionText::getUrl() . '] ' . $description;
     $body = ExceptionText::getBody($error . ':' . $description, $file, $line, $context);
     return ExceptionMail::send($subject, $body);
 }
 public function testNotFoundPageShowsCorrectCopyWhenVerboseErrorsDisabled()
 {
     $original = Settings::getSettings();
     $settings = $original;
     $settings['errors']['verbose'] = false;
     Settings::setFromArray($settings);
     try {
         $this->request->dispatch("/notfound");
     } catch (Exception $e) {
         $handler = new ErrorHandler();
         $handler->setRequest($this->request);
         $handler->handleError($e);
         $this->assertResponseCode(404, $handler->getResponse());
         $this->assertBodyHasContents("Oops! That&rsquo;s a 404", $handler->getResponse());
         $this->assertBodyHasContents("It looks like the page you&rsquo;re after doesn&rsquo;t exist", $handler->getResponse());
     }
     Settings::setFromArray($original);
 }
Exemplo n.º 12
0
 /**
  * HandleError
  *
  * @param integer $code Code of error
  * @param string $description Error description
  * @param string $file File on which error occurred
  * @param integer $line Line that triggered the error
  * @param array $context Context
  * @return boolean true if error was handled
  */
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     extract(self::handlerSettings());
     $args = compact('code', 'description', 'file', 'line', 'context', 'session');
     if ($emailNotifications === true && !empty($receiver)) {
         $cacheHash = 'error-' . md5(serialize(compact($args)));
         self::setCacheConfig($duration);
         if (Cache::read($cacheHash, 'error_handler') === false || $caching === false) {
             list($error, $log) = self::mapErrorCode($code);
             if (in_array($log, $logLevels) || in_array($code, $codes)) {
                 $trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
                 $session = CakeSession::read();
                 $server = $_SERVER;
                 $request = $_REQUEST;
                 $Email = self::getEmailInstance();
                 $Email->viewVars(compact('code', 'description', 'file', 'line', 'context', 'session', 'server', 'request', 'trace'));
                 $Email->send();
             }
             Cache::write($cacheHash, true, 'error_handler');
         }
     }
     return parent::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 13
0
 public function testHandleError()
 {
     $this->assertTrue(ErrorHandler::handleError('FooCode', 'FooMessage', 'FooFile', 'FooLine', 'FooContext'));
 }
Exemplo n.º 14
0
 /**
  * shut down functions handler
  *
  */
 public static function handleFatalError()
 {
     $error = error_get_last();
     ErrorHandler::handleError($error['type'], $error["message"], $error["file"], $error["line"]);
 }
Exemplo n.º 15
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     $errbitCake = new ErrbitCakePHP();
     $errbitCake->onError($code, $description, $file, $line);
     return parent::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 16
0
 /**
  * @see ErrorHandler::handleError
  */
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     $severity = Configure::read('Sentry.treatErrorAsWarning') === true ? E_WARNING : 1;
     $e = new ErrorException($description, $code, $severity, $file, $line);
     // Check that Sentry has captured the error
     if (self::sentryCapture($e)) {
         return parent::handleError($code, $description, $file, $line, $context);
     }
     return true;
 }
Exemplo n.º 17
0
<?php

namespace DYuriev;

/*
* @author: Dmitriy Yuriev <*****@*****.**>
* @product: error_handler
* @version: 1.1.1
* @release date: 27.07.2014
* @development started: 15.07.2014
* @license: GNU AGPLv3 <http://www.gnu.org/licenses/agpl.txt>
*
* A small useful library that helps to handle PHP fatal errors and exceptions.
* Supports messages on two languages: russian and english.
*/
error_reporting(-1);
ini_set("display_errors", "Off");
ini_set("display_startup_errors", "Off");
ini_set("html_errors", "Off");
define('ERROR_HANDLER_DIR', __DIR__);
require_once ERROR_HANDLER_DIR . '/class/ErrorHandler.class.php';
$error_handler = new ErrorHandler(\Swift_Mailer::newInstance(\Swift_MailTransport::newInstance()), \Swift_Message::newInstance());
set_error_handler(function ($err_no, $err_str, $err_file, $err_line) use($error_handler) {
    $error_handler->handleError($err_no, $err_str, $err_file, $err_line);
}, E_ALL | E_STRICT);
set_exception_handler(function ($exception) use($error_handler) {
    $error_handler->handleException($exception);
});
register_shutdown_function(function () use($error_handler) {
    $error_handler->handleShutdown();
});
Exemplo n.º 18
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     self::bugsnagHandleError($code, $description, $file, $line, $context);
     return parent::handleError($code, $description, $file, $line, $context);
 }
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     static::getBugsnag()->errorHandler($code, $description, $file, $line, $context);
     return parent::handleError($code, $description, $file, $line, $context);
 }
Exemplo n.º 20
0
$mode = getenv("PROJECT_MODE") !== false ? getenv("PROJECT_MODE") : "live";
//session_cache_limiter(false);
try {
    // make sure a request object is available as soon as possible
    $request = JaossRequest::getInstance();
    Settings::setMode($mode);
    include "library/boot.php";
    include "library/load_apps.php";
    if (Settings::getValue("date", "allow_from_cookie", false)) {
        $date = CookieJar::getInstance()->getCookie("test_date");
        if ($date !== null) {
            Utils::setCurrentDate($date);
        }
    }
    $request->dispatch();
    $response = $request->getResponse();
    /*
    $response->setIfNoneMatch(
        $request->getHeader('If-None-Match')
    );
    */
    $response->send();
} catch (Exception $e) {
    $handler = new ErrorHandler();
    $handler->setRequest($request);
    $handler->handleError($e);
    $response = $handler->getResponse();
    $response->send();
} catch (Exception $e) {
    exit($e->getMessage());
}
Exemplo n.º 21
0
 /**
  * fillContainerWithModule()
  */
 private function fillContainerWithModule($oContentObject, $oTemplate, $iModuleId)
 {
     $oPageContents = $oContentObject->getLanguageObject($this->sLanguageId);
     if ($this->bIsPreview && $oPageContents === null) {
         //Need to get unsaved drafts in preview
         $oPageContents = new LanguageObject();
         $oPageContents->setLanguageId($this->sLanguageId);
         $oPageContents->setContentObject($oContentObject);
         $oPageContents = $oPageContents->getDraft(true);
     }
     if ($oPageContents === null) {
         return false;
     }
     if ($oContentObject->getConditionSerialized() !== null && !$this->bIsPreview) {
         $oConditionTemplate = unserialize(stream_get_contents($oContentObject->getConditionSerialized()));
         if ($oConditionTemplate->render() === '') {
             return false;
         }
     }
     $sObjectType = $oContentObject->getObjectType();
     if (!Module::moduleExists($sObjectType, FrontendModule::getType()) || !Module::isModuleEnabled(FrontendModule::getType(), $sObjectType)) {
         $sLink = implode('/', $this->oNavigationItem->getLink());
         ErrorHandler::handleError(E_WARNING, "Disabled or non-existing frontend module {$sObjectType} in use on page {$sLink} ({$this->sLanguageId})", __FILE__, __LINE__, null, debug_backtrace(), true);
         if ($this->bIsPreview) {
             $oTemplate->replaceIdentifierMultiple("container", "<strong>Disabled or non-existing frontend module {$sObjectType} in use!</strong>", null, Template::NO_HTML_ESCAPE);
             return true;
         }
         return false;
     }
     if ($this->bIsPreview) {
         $oModule = FrontendModule::getModuleInstance($oContentObject->getObjectType(), $oPageContents->getDraft(), $iModuleId);
     } else {
         $oModule = FrontendModule::getModuleInstance($oContentObject->getObjectType(), $oPageContents, $iModuleId);
     }
     $sFrontentContents = $this->getModuleContents($oModule);
     if ($sFrontentContents === null) {
         return false;
     }
     // module_id
     FilterModule::getFilters()->handleDefaultPageTypeFilledContainerWithModule($oContentObject, $oModule, $oTemplate, $this->oFrontendTemplate, $this->iModuleId);
     if ($this->bIsPreview) {
         $sFrontentContents = $this->getPreviewMarkup($oContentObject, $sFrontentContents);
     }
     $oTemplate->replaceIdentifierMultiple("container", $sFrontentContents, null, Template::NO_HTML_ESCAPE);
     if (($sCss = $oModule->getCssForFrontend()) !== null) {
         ResourceIncluder::defaultIncluder()->addCustomCss($sCss, ResourceIncluder::PRIORITY_LAST);
     }
     if (($sJs = $oModule->getJsForFrontend()) !== null) {
         ResourceIncluder::defaultIncluder()->addCustomJs($sJs, ResourceIncluder::PRIORITY_LAST);
     }
     return true;
 }