public function action_show() { $status = $this->error instanceof HttpException ? $this->error->getStatus() : '500 Internal Server Error'; $data = $this->error instanceof HttpException ? $this->error->getData() : []; $this->response->add_header('HTTP/1.1 ' . $status); $displayErrors = $this->pixie->getParameter('parameters.display_errors', false); $showErrors = false; if ($this->error instanceof HttpException) { $message = $this->error->getMessage(); if ($this->error->getCode() >= 400 || $this->error->getCode() < 100) { $showErrors = $displayErrors; } } else { if ($this->error instanceof SQLException) { if ($this->error->isVulnerable() && !$this->error->isBlind()) { $showErrors = true; $message = $this->error->getMessage(); } else { $message = "Error"; } } else { $message = $this->error->getMessage(); $showErrors = $displayErrors; } } $this->response->body = array_merge(['message' => $message, 'code' => $this->error->getCode(), 'trace' => $showErrors ? $this->error->getTraceAsString() : ""], $data); }
public function onKernelResponse(FilterResponseEvent $event) { $debug = $this->container->getParameter('rest.config')['debug']; $arr = $event->getRequest()->headers->get("accept"); if (!is_array($arr)) { $arr = array($arr); } if (is_array($arr) && (in_array("text/html", $arr) || in_array("*/*", $arr))) { return; } $response = $event->getResponse(); if (in_array($response->headers->get("content-type"), $arr)) { return; } $error = $response->isServerError() || $event->getResponse()->isClientError(); if ($error && self::$exception != null) { $result = array(); $result["status"] = $response->getStatusCode(); if (self::$exception != null) { $result["message"] = self::$exception->getMessage(); if ($debug) { $result["stacktrace"] = self::$exception->getTraceAsString(); } } else { $result["message"] = "unknown"; if ($debug) { $result["stacktrace"] = ""; } } $classParser = $this->container->get("rest.internal_class_parser"); $content = $classParser->serializeObject($result, true); $response->setContent($content["result"]); $response->headers->add(array("content-type" => $content["type"])); } }
/** * @param \Exception $e * @return bool */ function exceptionHandler(\Exception $e) { echo '<h1>Error</h1><p>Sorry, the script died with a exception</p>'; echo $e->getMessage() . ' in <br>' . $e->getFile() . ': <br>' . $e->getLine(), ' : <br>', __FUNCTION__, ' : <br>', $e->getTraceAsString(); log::error($e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . "<br>\n", "Code: " . $e->getCode(), $e->getTrace()); mail(ADMIN_MAIL, '[GitReminder] System got locked', $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . "\n\n" . "Funktion -> " . __FUNCTION__ . $e->getTraceAsString() . "\n\n" . "Code: " . $e->getCode()); @trigger_error('', E_USER_ERROR); }
/** * @description Build message * * @return string */ public function exceptionMessage() { $msg = ''; if ($this->exception->getCode()) { $msg .= "Exception code: " . $this->exception->getCode() . PHP_EOL; } $msg .= $this->exception->getMessage() . PHP_EOL; $msg .= "At file: " . $this->exception->getFile(); $msg .= ": " . $this->exception->getLine() . PHP_EOL; $msg .= "Trace: " . PHP_EOL . $this->exception->getTraceAsString(); return $msg; }
/** * {@inheritdoc} */ public function getHttpException() { $code = 500; $message = ''; if (!$this->isProd()) { $message = $this->currentException->getMessage() . '<pre>' . $this->currentException->getTraceAsString() . '</pre>'; } if ($this->currentException instanceof HttpException) { $code = $this->currentException->getStatusCode(); } return new HttpException($code, $message, $this->currentException); }
/** * @param \Exception $e * @param string|bool $message * @return static */ public function logException(\Exception $e, $message = false) { $this->stream()->emptyLine(); $this->stream()->writeLine(str_repeat('*', 32)); if ($message) { $this->stream()->emptyLine(); $this->stream()->writeLine("[31m" . $message . "[0m"); } $this->stream()->emptyLine(); $this->stream()->writeLine("Err Message: {$e->getMessage()}"); $this->stream()->writeLine("At: {$e->getFile()}"); $this->stream()->writeLine("Line: {$e->getLine()}"); if ($e->getCode() != 0) { $this->stream()->writeLine("Code: " . $e->getLine()); } $this->stream()->writeLine('Stack: '); $this->stream()->emptyLine(); foreach (explode("\n", $e->getTraceAsString()) as $line) { $line = str_replace("\r", '', $line); $this->stream()->writeLine(" {$line}"); } $this->stream()->emptyLine(); $this->stream()->writeLine(str_repeat('*', 32)); $this->stream()->emptyLine(); return $this; }
/** * Render response body * @param array $env * @param \Exception $exception * @return string */ protected function renderBody(&$env, $exception) { $title = 'Slim Application Error'; $code = $exception->getCode(); $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $html = sprintf('<h1>%s</h1>', $title); $html .= '<p>The application could not run because of the following error:</p>'; $html .= '<h2>Details</h2>'; $html .= sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception)); if ($code) { $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code); } if ($message) { $html .= sprintf('<div><strong>Message:</strong> %s</div>', $message); } if ($file) { $html .= sprintf('<div><strong>File:</strong> %s</div>', $file); } if ($line) { $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line); } if ($trace) { $html .= '<h2>Trace</h2>'; $html .= sprintf('<pre>%s</pre>', $trace); } return sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body>%s</body></html>", $title, $html); }
function Error() { echo "У пользователя " . $this->user->SystemName() . " произошла ошибка: " . parent::getMessage(); if (DEBUG) { echo parent::getTraceAsString(); } }
function displayExceptionObject(Exception $e) { echo "\$e = >{$e}<\n"; // calls __toString echo "getMessage: >" . $e->getMessage() . "<\n"; echo "getCode: >" . $e->getCode() . "<\n"; echo "getPrevious: >" . $e->getPrevious() . "<\n"; echo "getFile: >" . $e->getFile() . "<\n"; echo "getLine: >" . $e->getLine() . "<\n"; echo "getTraceAsString: >" . $e->getTraceAsString() . "<\n"; $traceInfo = $e->getTrace(); var_dump($traceInfo); echo "Trace Info:" . (count($traceInfo) == 0 ? " none\n" : "\n"); foreach ($traceInfo as $traceInfoKey => $traceLevel) { echo "Key[{$traceInfoKey}]:\n"; foreach ($traceLevel as $levelKey => $levelVal) { if ($levelKey != "args") { echo " Key[{$levelKey}] => >{$levelVal}<\n"; } else { echo " Key[{$levelKey}]:\n"; foreach ($levelVal as $argKey => $argVal) { echo " Key[{$argKey}] => >{$argVal}<\n"; } } } } }
/** * new exception * @param Exception $exception * @param boolean $printError show error or not * @param boolean $clear clear the errorlog * @param string $errorFile file to save to */ public static function newMessage(\Exception $exception) { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $date = date('Y-m-d H:i:s'); $logMessage = "<h3>Exception information:</h3>\n\n <p><strong>Date:</strong> {$date}</p>\n\n <p><strong>Message:</strong> {$message}</p>\n\n <p><strong>Code:</strong> {$code}</p>\n\n <p><strong>File:</strong> {$file}</p>\n\n <p><strong>Line:</strong> {$line}</p>\n\n <h3>Stack trace:</h3>\n\n <pre>{$trace}</pre>\n\n <hr />\n"; if (is_file(self::$errorFile) === false) { file_put_contents(self::$errorFile, ''); } if (self::$clear) { $f = fopen(self::$errorFile, "r+"); if ($f !== false) { ftruncate($f, 0); fclose($f); } $content = null; } else { $content = file_get_contents(self::$errorFile); } file_put_contents(self::$errorFile, $logMessage . $content); //send email if (MAIL_ERROR === true) { self::sendEmail($logMessage); } }
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { $class = get_class($test); $message = $this->escape("Exception: {$e->getMessage()}"); $trace = $this->escape($e->getTraceAsString()); echo "##teamcity[testFailed type='exception' name='{$class}.{$test->getName()}' message='{$message}'" . " details='{$trace}']\n"; }
public static function log_writer(\Exception $exception, $clear = false, $error_file = 'ex_log.html') { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $date = date('M d, Y h:iA'); $log_message = "<h3>Exception information:</h3>\n\t\t<p>\n\t\t<strong>Date:</strong> {$date}\n\t\t</p>\n\n\t\t<p>\n\t\t<strong>Message:</strong> {$message}\n\t\t</p>\n\t\t\t\n\t\t<p>\n\t\t<strong>Code:</strong> {$code}\n\t\t</p>\n\n\t\t<p>\n\t\t<strong>File:</strong> {$file}\n\t\t</p>\n\n\t\t<p>\n\t\t<strong>Line:</strong> {$line}\n\t\t</p>\n\n\t\t<h3>Stack trace:</h3>\n\t\t<pre>{$trace}</pre>\n\t\t\n\t\t<h3>Request information:</h3>\n\t\t<pre>"; foreach ($_REQUEST as $key => $value) { $log_message .= "<strong>{$key}</strong>: {$value}<br/>"; } $log_message .= "</pre>"; $log_message .= "<h3>Server information:</h3>\n\t\t<pre>"; foreach ($_SERVER as $key => $value) { $log_message .= "<strong>{$key}</strong>: {$value}<br/>"; } $log_message .= "</pre>\n\t\t<br />\n\t\t<hr /><br /><br />"; if (is_file($error_file) === false) { file_put_contents($error_file, ''); } if ($clear) { $content = ''; } else { $content = file_get_contents($error_file); } file_put_contents($error_file, $log_message . $content); }
/** * Trace exception for more readable * @static * @param Exception $e * @return unknown */ public static function trace(Exception $e) { echo '<pre>'; echo 'Caught Hush Exception at ' . date('Y-m-d H:i:s') . ' : ' . $e->getMessage() . "\n"; echo $e->getTraceAsString() . "\n"; echo '</pre>'; }
/** * Process exception * * @param \Exception $exception * @param string[] $params * @return void */ public function processException(\Exception $exception, array $params = array()) { echo '<pre>'; echo $exception->getMessage() . "\n\n"; echo $exception->getTraceAsString(); echo '</pre>'; }
/** * Método utilizado internamente para exibição de excessões não capturadas durante o desenvolvimento. * * @param Exception $e */ function uncaughtExceptionHandler($e) { $trace = str_replace('#', '<br /><br />', $e->getTraceAsString()); $html = "<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>Anna: Erro</title>\n\t\t\t\t\t<link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css' />\n\t\t\t\t\t<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' rel='stylesheet' type='text/css'>\n\t\t\t\t\t<meta charset='utf-8' content='text/html' />\n\t\t\t\t</head>\n\t\t\t\t<body style=\"font-family: 'Source Sans Pro', serif; font-weight: 600\">\n\t\t\t\t\t<h1 style=\"font-family: 'Roboto Slab', serif;\n\t\t\t\t\t\t\t\twidth: 800px;\n\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\tmargin: auto;\n\t\t\t\t\t\t\t\tbackground-color: #FFF5F6;\n\t\t\t\t\t\t\t\tborder-radius: 5px;\n\t\t\t\t\t\t\t\tborder: 1px solid #CACACA;\n\t\t\t\t\t\t\t\tpadding: 10px 0 10px 0;\n\t\t\t\t\t\t\t\tcolor: #8C1C1C;\">Parece que houve um erro:</h1>\n\t\t\t\t\t<div style='width: 800px;\n\t\t\t\t\t\t\t\tmargin: 0 auto;\n\t\t\t\t\t\t\t\tbackground-color: #EFEFEF;\n\t\t\t\t\t\t\t\tpadding: 10px;\n\t\t\t\t\t\t\t\tmargin-top: 21px;\n\t\t\t\t\t\t\t\tborder-radius: 5px;\n\t\t\t\t\t\t\t\tborder: 1px solid #C7C7C7;'>\n\t\t\t\t\t\t<h3>{$e->getMessage()}</h3>\n\t\t\t\t\t\t<p><b>{$e->getFile()}</b>, na linha: <b>{$e->getLine()}</b></p>\n\t\t\t\t\t\t<p>{$trace}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</body>\n\t\t\t</html>"; $response = new Anna\Response($html, 200, ['chaset' => 'utf-8']); $response->send(); }
function __phutil_signal_handler__($signal_number) { $e = new Exception(); $pid = getmypid(); // Some phabricator daemons may not be attached to a terminal. Filesystem::writeFile(sys_get_temp_dir() . '/phabricator_backtrace_' . $pid, $e->getTraceAsString()); }
public function handleSignal(PhutilSignalRouter $router, $signo) { $e = new Exception(); $pid = getmypid(); // Some Phabricator daemons may not be attached to a terminal. Filesystem::writeFile(sys_get_temp_dir() . '/phabricator_backtrace_' . $pid, $e->getTraceAsString()); }
public function index(\Exception $e, Request $request, $code) { if ($this->debug) { return $this->render(["code" => $code, "message_pre" => true, "message" => print_r(["Message" => $e->getMessage(), "Trace" => explode("\n", $e->getTraceAsString())], true), "video" => false]); } return $this->render(["code" => $code, "message" => $this->getMessage($code), "video" => $this->getVideo($code), "message_pre" => false]); }
/** * Handle exception * * @param \Exception $e * @return \Psr\Http\Message\ResponseInterface */ public function handle(\Exception $e) { $response = $this->provider->getResponse(); $response = $response->withStatus(500); $message = 'Internal Server Error'; $view = $this->provider->getView(); if ($this->provider->getConfig('display_exceptions')) { $view->exception = $e; } $view->message = $message; $config = $this->provider->getConfig(); if (isset($config['templates']['template_error'])) { $result = $view->renderFile($config['templates']['template_error']); } else { if (isset($view->exception)) { $body = sprintf("<h1>An error occurred</h1><h2>%s</h2><h3>Message</h3><p>%s</p><h3>Stack trace</h3><p>%s</p>", $message, $e->getMessage(), $e->getTraceAsString()); } else { $body = sprintf("<h1>An error occurred</h1><h2>%s</h2>", $message); } $result = sprintf("<html><head><title>%s</title><style>body {font-family: Helvetica,Arial,sans-serif;font-size: 20px;line-height: 28px;padding:20px;}</style></head><body>%s</body></html>", 'Tlumx application: ' . $message, $body); } $response->getBody()->write($result); $response->withHeader('Content-Type', 'text/html'); return $response; }
function write_log($type, $level, $message, Exception &$throwable = NULL) { if ($throwable != null) { $message = $message . ' at ' . $throwable->getFile() . ':' . $throwable->getLine() . "\r\n" . $throwable->getTraceAsString(); } file_put_contents(NWTS_LOG_DIR . DIRECTORY_SEPARATOR . $type . '.log', date('Y-m-d H:i:s', time()) . ' ' . $level . ' ' . $message . "\r\n", FILE_APPEND | LOCK_EX); }
/** * Creates the query necessary to pull all of the data from a table. * * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData * @return unknown */ public static function buildTableSelect(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData, PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection = NULL) { if ($tableMetaData->getTableName() == '') { $e = new Exception('Empty Table Name'); echo $e->getTraceAsString(); throw $e; } $columns = $tableMetaData->getColumns(); if ($databaseConnection) { $columns = array_map([$databaseConnection, 'quoteSchemaObject'], $columns); } $columnList = implode(', ', $columns); if ($databaseConnection) { $tableName = $databaseConnection->quoteSchemaObject($tableMetaData->getTableName()); } else { $tableName = $tableMetaData->getTableName(); } $primaryKeys = $tableMetaData->getPrimaryKeys(); if ($databaseConnection) { $primaryKeys = array_map([$databaseConnection, 'quoteSchemaObject'], $primaryKeys); } if (count($primaryKeys)) { $orderBy = 'ORDER BY ' . implode(' ASC, ', $primaryKeys) . ' ASC'; } else { $orderBy = ''; } return "SELECT {$columnList} FROM {$tableName} {$orderBy}"; }
function QcodoHandleException(Exception $__exc_objException) { QApplication::$ErrorFlag = true; global $__exc_strType; if (isset($__exc_strType)) { return; } $__exc_objReflection = new ReflectionObject($__exc_objException); $__exc_strType = "Exception"; $__exc_strMessage = $__exc_objException->getMessage(); $__exc_strObjectType = $__exc_objReflection->getName(); if ($__exc_objException instanceof QDatabaseExceptionBase) { $__exc_objErrorAttribute = new QErrorAttribute("Database Error Number", $__exc_objException->ErrorNumber, false); $__exc_objErrorAttributeArray[0] = $__exc_objErrorAttribute; if ($__exc_objException->Query) { $__exc_objErrorAttribute = new QErrorAttribute("Query", $__exc_objException->Query, true); $__exc_objErrorAttributeArray[1] = $__exc_objErrorAttribute; } } $__exc_strFilename = $__exc_objException->getFile(); $__exc_intLineNumber = $__exc_objException->getLine(); $__exc_strStackTrace = trim($__exc_objException->getTraceAsString()); if (ob_get_length()) { $__exc_strRenderedPage = ob_get_contents(); ob_clean(); } // Call to display the Error Page (as defined in configuration.inc.php) require __DOCROOT__ . ERROR_PAGE_PATH; exit; }
function drop() { call_user_func_array("var_dump", func_get_args()); $e = new Exception(); echo "-------\nDump trace: \n" . $e->getTraceAsString() . "\n"; exit; }
/** * Show exception screen * * @param \Exception $exception */ public function showException(\Exception $exception) { @ob_end_clean(); $msg = sprintf("%s\nFile: %s\nLine: %d\nTrace:\n%s", $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString()); \Kalibri::logger()->add(Logger::L_EXCEPTION, $msg); $viewName = \Kalibri::config()->get('error.view.exception'); if ($viewName) { $view = new \Kalibri\View($viewName); $view->ex = $exception; $str = ''; $file = \fopen($exception->getFile(), 'r'); for ($i = 0; $i < $exception->getLine() - 16; $i++) { \fgets($file); } for ($i = 0; $i < 20; $i++) { $str .= \fgets($file); } $view->code = Highlight::php($str, true, 1, $exception->getLine()); if ($view->isExists()) { $view->render(); } else { // Fallback to show any message in case if exception view not found or not set echo "<h1>Exception</h1><p>{$exception->getMessage()}</p>"; } } exit; }
/** * @param Exception $e * @param bool $html * * @return string */ private function getExceptionStackTrace(\Exception $e, $html = true) { $wrap = $html ? ['<b>', '</b>'] : ['', '']; $bold = function ($s) use($wrap) { return implode($s, $wrap); }; $newLine = $html ? '<br>' : "\n"; $trace = $bold('Error Time :') . date('Y-m-d H:i:s A'); $trace .= $newLine . $bold('Error Code :') . $e->getCode(); $trace .= $newLine . $bold('Error Message :') . $e->getMessage(); $trace .= $newLine . $bold('Error File :') . $e->getFile(); $trace .= $newLine . $bold('Error File Line :') . $e->getLine(); $trace .= $newLine . $bold('Error Trace :') . $newLine; $trace .= $html ? preg_replace("/\n/", '<br>', $e->getTraceAsString()) : $e->getTraceAsString(); return $trace; }
/** * Render response body * @param array $env * @param \Exception $exception * @return string */ protected function renderBody(&$env, $exception) { $title = 'Oops! Exception detected'; $code = $exception->getCode(); $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = str_replace(array('#', '\\n'), array('<div>#', '</div>'), $exception->getTraceAsString()); $html = sprintf('<h1>%s</h1>', $title); $html .= '<p>Something is broken, the application could not run, Pulse has detected the following error:</p>'; $html .= '<h2>Details</h2>'; $html .= sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception)); if ($code) { $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code); } if ($message) { $html .= sprintf('<div><strong>Message:</strong> %s</div>', $message); } if ($file) { $html .= sprintf('<div><strong>File:</strong> %s</div>', $file); } if ($line) { $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line); } if ($trace) { $html .= '<h2>Trace</h2>'; $html .= sprintf('<pre>%s</pre>', $trace); } return sprintf("<!doctype html><html lang=\"es\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"" . asset('bootstrap.min.css') . "\"><link rel=\"stylesheet\" href=\"" . asset('styles.css') . "\"><title>%s</title><link rel=\"icon\" type=\"image/png\" href=\"" . asset('pulseLogo.png') . "\" /></head><body><nav class=\"navbar navbar-inverse navbar-fixed-top\"> <div class=\"container\"><div class=\"navbar-header\"><button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#navbar\" aria-expanded=\"false\" aria-controls=\"navbar\"><span class=\"sr-only\">Toggle navigation</span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span></button><a class=\"navbar-brand\" href=\"" . basePath() . "\"><img src=\"" . asset('pulseLogo.png') . "\" width=\"25\"> PULSE Framework</a></div><div id=\"navbar\" class=\"collapse navbar-collapse\"><ul class=\"nav navbar-nav\"><li><a href=\"" . basePath() . "\">Página principal</a></li><li><a href=\"" . uri('documentationUrl') . "\">Documentation</a></li><li><a href=\"" . uri('communityUrl') . "\">Pulse Community</a></li><li><a href=\"" . uri('tutosUrl') . "\">Tutorials</a></li></ul></div></div></nav><div class=\"container\"><div class=\"starter-template\">%s</div></div><script src=\"" . asset('jquery.min.js') . "\"></script><script src=\"" . asset('bootstrap.min.js') . "\"></script></body></html>", $title, $html); }
public function logException(Exception $exception, $order_id, $type, $line_nuber = '') { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $date = date('M d, Y h:iA'); if ($type == 'order') { $log_message = "<p><strong>Order Id:</strong> {$order_id}\r\n\t\t <p><strong>Error Message:</strong> {$message}</p>\r\n <p><strong>Line Number:</strong> {$line_nuber}</p>"; } else { if ($type == 'invoice') { $log_message = "<p><strong>Invoice Error : </strong></p>\r\n\t\t <p><strong>Order Id:</strong> {$order_id}</p>\r\n <p><strong>Error Message:</strong> {$message}</p>"; } else { if ($type == 'shipment') { $log_message = "<p><strong>Shipment Error : </strong></p>\r\n\t\t <p><strong>Order Id:</strong> {$order_id}</p>\r\n <p><strong>Error Message:</strong> {$message}</p>"; } else { if ($type == 'creditmemo') { $log_message = "<p><strong>Creditmemo Error : </strong></p>\r\n\t\t <p><strong>Order Id:</strong> {$order_id}</p>\r\n <p><strong>Error Message:</strong> {$message}</p>"; } } } } if (is_file($this->error_file) === false) { file_put_contents($this->error_file, ''); } $content = file_get_contents($this->error_file); file_put_contents($this->error_file, $content . $log_message); }
public function decodeObject($str, $assoc = false, $loadAmazonClasses = false) { // load Amazon classes if required // if ( $loadAmazonClasses ) self::loadAmazonClasses(); if ($str == '') { return false; } // json_decode $obj = json_decode($str, $assoc); //WPLA()->logger->info('json_decode: '.print_r($obj,1)); if (is_object($obj) || is_array($obj)) { return $obj; } // unserialize fallback $obj = maybe_unserialize($str); //WPLA()->logger->info('unserialize: '.print_r($obj,1)); if (is_object($obj) || is_array($obj)) { return $obj; } // mb_unserialize fallback $obj = $this->mb_unserialize($str); // WPLA()->logger->info('mb_unserialize: '.print_r($obj,1)); if (is_object($obj) || is_array($obj)) { return $obj; } // log error $e = new Exception(); WPLA()->logger->error('backtrace: ' . $e->getTraceAsString()); WPLA()->logger->error('mb_unserialize returned: ' . print_r($obj, 1)); WPLA()->logger->error('decodeObject() - not an valid object: ' . $str); return $str; }
public static function handle_exception(Exception $e) { echo "<div class='error'>{Exception handler}" . PHP_EOL . "[" . $e->getCode() . "] " . $e->getMessage() . "<br />" . PHP_EOL; echo "Line [" . $e->getLine() . "] in file [" . $e->getFile() . "]<br />" . PHP_EOL . $e->getTraceAsString() . "<br />" . PHP_EOL; echo "</div>" . PHP_EOL; return true; }
public static function insert($action, $type, $creator = null, $related = null, array $metaData = array(), Exception $exception = null, PropelPDO $con) { $activity = new Activity(); if ($creator instanceof Member) { $activity->setMemberId($creator->getId()); } else { if (is_numeric($creator)) { $activity->setMemberId($creator); } } if ($related) { if (is_numeric($related)) { $activity->setRelatedId($related); } else { if (is_callable($related, 'getId')) { $activity->setRelatedId($related->getId()); } } } $activity->setAction($action)->setType($type)->setDate(time()); try { if ($exception != null && !isset($metaData['exception'])) { $metaData['exception'] = array('message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()); } $activity->setMeta($metaData)->save($con); } catch (Exception $e) { error_log(__METHOD__ . ': ' . $e->__toString() . ': ' . var_export($metaData, true)); throw $e; } return $activity; }