Пример #1
0
function exception_handler($e)
{
    if (!$e instanceof \OutOfBoundsException) {
        try {
            $err = Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . Lampcms\Exception::formatException($e));
            $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no extra';
            if (defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 1) {
                @mail(LAMPCMS_DEVELOPER_EMAIL, 'ErrorHandle in inc.php', $err . $extra);
            }
            echo $err;
        } catch (\Exception $e) {
            echo 'Error in Exception handler: : ' . $e->getMessage() . ' line ' . $e->getLine() . $e->getTraceAsString();
        }
    } else {
        d('Got exit signal in error_handler from ' . $e->getTraceAtString());
    }
}
Пример #2
0
function exception_handler($e)
{
    $code = $e->getCode();
    if (!$e instanceof \OutOfBoundsException) {
        try {
            $err = Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . Lampcms\Exception::formatException($e));
            $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no extra';
            if ($code >= 0 && defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
                @mail(LAMPCMS_DEVELOPER_EMAIL, 'ErrorHandle in inc.php', $err . $extra);
            }
            echo nl2br($err);
        } catch (\Exception $e) {
            echo 'Error in Exception handler: : ' . $e->getMessage() . ' line ' . $e->getLine() . $e->getTraceAsString();
        }
    } else {
        echo 'Got exit signal in error_handler. Exception: ' . get_class($e) . ' Error ' . $e->getMessage() . ' in:  ' . $e->getFile() . ' line: ' . $e->getLine() . "\n<br>Trace: " . $e->getTraceAsString();
    }
}
Пример #3
0
         d('Got exit signal from ' . $e->getTraceAsString());
     }
     fastcgi_finish_request();
 } catch (\Exception $e) {
     session_write_close();
     header("HTTP/1.0 500 Exception");
     try {
         /**
          * @mail must be here before the Lampcms\Exception::formatException
          * because Lampcms\Exception::formatException in case of ajax request will
          * send out ajax and then throw \OutOfBoundsException in order to finish request (better than exit())
          */
         if (defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
             @mail(LAMPCMS_DEVELOPER_EMAIL, '500 Error in index.php', $sHtml . $extra);
         }
         $sHtml = \Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . Lampcms\Exception::formatException($e));
         $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no server';
         $extra .= 'file: ' . $e->getFile() . ' line: ' . $e->getLine() . ' trace: ' . $e->getTraceAsString();
         echo $sHtml;
     } catch (\OutOfBoundsException $e2) {
         // do nothing, this was a way to exit() from Responder::sendJSON()
     } catch (\Exception $e2) {
         $sHtml = \Lampcms\Responder::makeErrorPage('<strong>Exception:</strong> ' . strip_tags($e2->getMessage()) . "\nIn file:" . $e2->getFile() . "\nLine: " . $e2->getLine());
         $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no extra';
         if (defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
             @mail(LAMPCMS_DEVELOPER_EMAIL, 'Error in index.php on line ' . __LINE__, $sHtml . $extra);
         }
         echo $sHtml;
     }
     fastcgi_finish_request();
 }