/**
  * Writes exception to different logs
  *
  * @param \Exception|\Throwable $exception The exception(PHP 5.x) or throwable(PHP >= 7.0) object.
  * @param string $context The context where the exception was thrown, WEB or CLI
  * @return void
  * @see \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(), \TYPO3\CMS\Core\Utility\GeneralUtility::devLog()
  * @TODO #72293 This will change to \Throwable only if we are >= PHP7.0 only
  */
 protected function writeLogEntries($exception, $context)
 {
     // Do not write any logs for this message to avoid filling up tables or files with illegal requests
     if ($exception->getCode() === 1396795884) {
         return;
     }
     $filePathAndName = $exception->getFile();
     $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
     $logTitle = 'Core: Exception handler (' . $context . ')';
     $logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
     if ($context === 'WEB') {
         $logMessage .= '. Requested URL: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
     }
     $backtrace = $exception->getTrace();
     // Write error message to the configured syslogs
     GeneralUtility::sysLog($logMessage, $logTitle, GeneralUtility::SYSLOG_SEVERITY_FATAL);
     // When database credentials are wrong, the exception is probably
     // caused by this. Therefor we cannot do any database operation,
     // otherwise this will lead into recurring exceptions.
     try {
         // Write error message to devlog
         // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
         if (TYPO3_EXCEPTION_DLOG) {
             GeneralUtility::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace));
         }
         // Write error message to sys_log table
         $this->writeLog($logTitle . ': ' . $logMessage);
     } catch (\Exception $exception) {
     }
 }
Ejemplo n.º 2
0
function handler_exception(Exception $e)
{
    if (APPLICATION_ENV == 'testing') {
        print $e->getMessage() . PHP_EOL;
        return;
    }
    error_log($e->getMessage());
    if (defined('BB_MODE_API')) {
        $code = $e->getCode() ? $e->getCode() : 9998;
        $result = array('result' => NULL, 'error' => array('message' => $e->getMessage(), 'code' => $code));
        print json_encode($result);
        return false;
    }
    $page = "<!DOCTYPE html>\n    <html lang=en>\n    <meta charset=utf-8>\n    <title>Error</title>\n    <style>\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;min-height:180px;padding:30px 0 15px}* > body{padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0} em{font-weight:bold}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}pre{ width: 100%; overflow:auto; }\n    </style>\n    <a href=//www.boxbilling.com/ target='_blank'><img src='https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png' alt='BoxBilling' style='height:60px'></a>\n    ";
    $page = str_replace(PHP_EOL, "", $page);
    print $page;
    if ($e->getCode()) {
        print sprintf('<p>Code: <em>%s</em></p>', $e->getCode());
    }
    print sprintf('<p>%s</p>', $e->getMessage());
    print sprintf('<p><a href="http://www.boxbilling.com/docs/search.html?q=%s" target="_blank">Look for detailed error explanation</a></p>', urlencode($e->getMessage()));
    if (defined('BB_DEBUG') && BB_DEBUG) {
        print sprintf('<em>%s</em>', 'Set BB_DEBUG to FALSE, to hide the message below');
        print sprintf('<p>Class: "%s"</p>', get_class($e));
        print sprintf('<p>File: "%s"</p>', $e->getFile());
        print sprintf('<p>Line: "%s"</p>', $e->getLine());
        print sprintf('Trace: <pre>%s</pre>', $e->getTraceAsString());
    }
}
Ejemplo n.º 3
0
 /**
  * Get a human-readable version of the exception error code.
  *
  * @return string
  */
 public function severity()
 {
     if (array_key_exists($this->exception->getCode(), $this->levels)) {
         return $this->levels[$this->exception->getCode()];
     }
     return $this->exception->getCode();
 }
Ejemplo n.º 4
0
 /**
  * After action.
  *
  * @param \CInlineAction $action Action from controller
  *
  * @return \Docolight\Http\Response
  */
 public function afterAction($action)
 {
     parent::afterAction($action);
     // Basic data template
     $statusCode = 200;
     $data = array('status' => $statusCode, 'message' => 'Success', 'value' => $this->data);
     // Let's find an error
     if ($this->error instanceof Exception) {
         // throw $this->error;
         // Basic data template for an exception
         $statusCode = 500;
         $data = ['status' => $statusCode, 'message' => 'Error', 'value' => ['code' => $this->error->getCode(), 'message' => $this->error->getMessage()]];
         // If exception code is an HTTP resoponse code
         if ($message = Response::getMessageForCode($this->error->getCode())) {
             $statusCode = $this->error->getCode();
             $data['status'] = $statusCode;
             $data['message'] = preg_replace('/^\\d+ /', '', $message);
         } else {
             if (YII_DEBUG) {
                 $data['value']['stack_trace'] = $this->error->getTrace();
             }
         }
     } elseif ($this->data instanceof Response) {
         return $this->data->send();
     }
     return response('json', $statusCode, collect($data), $this->headers)->send();
 }
Ejemplo n.º 5
0
 public function validationError($field, $data, \Exception $e)
 {
     $fex = new ValidatorException(sprintf($this->standardMessage, $field, $e->getMessage(), $e->getCode()), $e->getCode(), $e);
     $fex->field = $field;
     $fex->data = $data;
     return $fex;
 }
 /**
  * Writes exception to different logs
  *
  * @param Exception $exception The exception
  * @param string 	the context where the exception was thrown, WEB or CLI
  * @return void
  * @see t3lib_div::sysLog(), t3lib_div::devLog()
  */
 protected function writeLogEntries(Exception $exception, $context)
 {
     $filePathAndName = $exception->getFile();
     $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
     $logTitle = 'Core: Exception handler (' . $context . ')';
     $logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
     $backtrace = $exception->getTrace();
     // write error message to the configured syslogs
     t3lib_div::sysLog($logMessage, $logTitle, 4);
     // When database credentials are wrong, the exception is probably
     // caused by this. Therefor we cannot do any database operation,
     // otherwise this will lead into recurring exceptions.
     try {
         // In case an error occurs before a database connection exists, try
         // to connect to the DB to be able to write the devlog/sys_log entry
         if (isset($GLOBALS['TYPO3_DB']) && is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) {
             $GLOBALS['TYPO3_DB']->connectDB();
         }
         // write error message to devlog
         // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
         if (TYPO3_EXCEPTION_DLOG) {
             t3lib_div::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace));
         }
         // write error message to sys_log table
         $this->writeLog($logTitle . ': ' . $logMessage);
     } catch (Exception $exception) {
         // Nothing happens here. It seems the database credentials are wrong
     }
 }
Ejemplo n.º 7
0
 public function run()
 {
     if (Yii::$app->response->format == Response::FORMAT_HTML) {
         if ($this->debug || null === $this->exceptionView) {
             $file = $this->errorHandler->exceptionView;
             $this->response->data = $this->errorHandler->renderFile($file, ['exception' => $this->exception]);
             return $this->response;
         } else {
             return $this->controller->render($this->exceptionView, ['exception' => $this->exception]);
         }
     }
     if ($this->exception instanceof HttpException) {
         $code = $this->exception->statusCode;
     } elseif ($this->exception instanceof ResultsException || $this->exception instanceof UserException) {
         $code = $this->exception->getCode();
     } else {
         $code = 500;
     }
     if ($this->exception instanceof ResultsException) {
         $isSuccess = $this->exception->isSuccess;
     } else {
         $isSuccess = false;
     }
     $data = $this->exception instanceof ResultsException ? $this->exception->data : null;
     if ($this->debug) {
         $debugBacktrace = $this->convertExceptionToArray($this->exception);
     } else {
         $debugBacktrace = null;
     }
     return $this->controller->formatResults($code, $data, $isSuccess, $debugBacktrace, $this->exception->getMessage());
 }
Ejemplo n.º 8
0
 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);
     $this->response->body = array_merge(['message' => $this->error->getMessage(), 'code' => $this->error->getCode()], $data);
 }
 /**
  * Writes exception to different logs
  *
  * @param Exception $exception The exception
  * @param string $context The context where the exception was thrown, WEB or CLI
  * @return void
  * @see t3lib_div::sysLog(), t3lib_div::devLog()
  */
 protected function writeLogEntries(\Exception $exception, $context)
 {
     $filePathAndName = $exception->getFile();
     $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
     $logTitle = 'Core: Exception handler (' . $context . ')';
     $logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
     if ($context === 'WEB') {
         $logMessage .= '. Requested URL: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
     }
     $backtrace = $exception->getTrace();
     // Write error message to the configured syslogs
     \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($logMessage, $logTitle, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_FATAL);
     // When database credentials are wrong, the exception is probably
     // caused by this. Therefor we cannot do any database operation,
     // otherwise this will lead into recurring exceptions.
     try {
         // In case an error occurs before a database connection exists, try
         // to connect to the DB to be able to write the devlog/sys_log entry
         if (isset($GLOBALS['TYPO3_DB']) && is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) {
             $GLOBALS['TYPO3_DB']->connectDB();
         }
         // Write error message to devlog
         // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
         if (TYPO3_EXCEPTION_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace));
         }
         // Write error message to sys_log table
         $this->writeLog($logTitle . ': ' . $logMessage);
     } catch (\Exception $exception) {
     }
 }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
 /**
  * Render an exception using ErrorController.
  *
  * @param \Exception $e
  *
  * @return \Illuminate\Http\Response
  */
 protected function renderControllerException(\Exception $e)
 {
     $code = 500;
     if ($e instanceof HttpResponseException) {
         $code = $e->getStatusCode();
     } else {
         if ($e->getCode() > 0) {
             $code = $e->getCode();
         }
     }
     try {
         /** @var ErrorController $controller */
         $controller = app()->make(ErrorController::class);
         if (method_exists($controller, 'error' . $code)) {
             $action = 'error' . $code;
         } else {
             $action = 'errorDefault';
         }
         $response = $controller->callAction($action, [$e]);
         if (!$response instanceof Response) {
             $response = new Response($response);
         }
         return $this->toIlluminateResponse($response, $e);
     } catch (\Exception $ex) {
         return $this->toIlluminateResponse($this->convertExceptionToResponse($ex), $ex);
     }
 }
Ejemplo n.º 12
0
 /**
  * handle() hook.
  *
  * @param App $app
  * @param BaseException $e
  * @return void
  */
 public function handle(App $app, BaseException $e)
 {
     $reg = $app['reg'];
     /* @var Registry $reg */
     $tpl = $app['tpl'];
     /* @var Tpl $tpl */
     $router = $app['router'];
     /* @var Router $router */
     switch ($reg->get('app.mode')) {
         case 'web':
             $httpStatus = 500;
             $tplName = 'exceptions/common.twig';
             $reg->set('page.title', trans('error', array('code' => $e->getCode())));
             if ($e instanceof HttpException) {
                 $httpStatus = $e->getCode();
             }
             if ($e instanceof ForbiddenException) {
                 $tplName = 'exceptions/http-403.twig';
             }
             if ($e instanceof NotFoundException) {
                 $tplName = 'exceptions/http-404.twig';
             }
             if ($e instanceof MethodNotAllowedException) {
                 $tplName = 'exceptions/http-405.twig';
             }
             $content = $tpl->renderFile($tplName, array('header' => $reg->get('page.title'), 'message' => $e->getMessage(), 'exception' => $e));
             $response = $router->createResponse($content, $httpStatus);
             $response->send();
             break;
         case 'cli':
             break;
     }
 }
Ejemplo n.º 13
0
/**
 * @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);
}
Ejemplo n.º 14
0
 public function uncaughtExceptionHandler(Exception $e)
 {
     if ($e->getCode() != 0) {
         $this->dieWithFaultResponse($e->getCode(), $e->getMessage());
     } else {
         $this->handleInternalError($e->getMessage(), $e->getFile(), $e->getLine());
     }
 }
Ejemplo n.º 15
0
/**
 * Handle a exception in the console environment. Prints a message to stderr.
 *
 * @param Exception $exception The exception to handle
 * @return void
 */
	public function handleException(Exception $exception) {
		$stderr = self::getStderr();
		$stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
			$exception->getMessage(),
			$exception->getTraceAsString()
		));
		$this->_stop($exception->getCode() ? $exception->getCode() : 1);
	}
Ejemplo n.º 16
0
 /**
  * @param \Exception $e
  */
 public function handleException(\Exception $e)
 {
     $code = $e->getCode() >= 400 ? $e->getCode() : 500;
     $exceptionData = ['error' => ['code' => $e->getCode(), 'message' => $e->getMessage()]];
     http_response_code($code);
     echo json_encode($exceptionData, JSON_PRETTY_PRINT);
     exit(1);
 }
Ejemplo n.º 17
0
 protected function process_exception(\Exception $ex)
 {
     $ret = array();
     $ret['error'] = $ex->getMessage();
     if ($ex->getCode()) {
         $ret['code'] = $ex->getCode();
     }
     return $ret;
 }
Ejemplo n.º 18
0
 public static function exception_handler(\Exception $e)
 {
     $severity = !isset(static::$levels[$e->getCode()]) ? $e->getCode() : static::$levels[$e->getCode()];
     logger(Fuel::L_ERROR, $severity . ' - ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
     if (\Fuel::$env != Fuel::PRODUCTION) {
         static::show_php_error($e);
     } else {
         echo 'An unrecoverable exception was thrown.';
     }
 }
Ejemplo n.º 19
0
 /**
  * Exception Handler Callback
  * Rethrows uncatched Exceptions in our presentation style.
  *
  * @see http://php.net/manual/de/function.set-exception-handler.php
  *
  * @param $exception PHP Exception Objects are valid (Type Hint).
  */
 public function handle(\Exception $exception)
 {
     if ($exception->getCode() > 0) {
         self::fetchExceptionTemplates($exception->getCode());
     }
     echo YellowScreenOfDeath::renderException($exception->getMessage(), $exception->getTraceAsString(), $exception->getCode(), $exception->getFile(), $exception->getLine(), $exception->getTrace());
     // we use our own exception handler here, so PHP returns exit code 0.
     // the execution will stop anyway, but let's return the correct code.
     \Koch\Tools\ApplicationQuit::quit(255);
 }
Ejemplo n.º 20
0
 protected function getDisplayedErrorMessage(\Exception $e)
 {
     if ($e instanceof ResourceFetcherException && $e->getCode() == 1) {
         return "The requested file could not be retrieved.";
     } else {
         if ($e instanceof ResourceWriterException && $e->getCode() == 1) {
             return "An unexpected error occurred and the file could not be written.";
         }
     }
     return $e->getMessage();
 }
Ejemplo n.º 21
0
 /**
  * Extract from exception an error message, HTTP response code, and whether
  * the exception should be logged
  */
 public static function parseException(Exception $e)
 {
     $error = array('exception' => $e);
     $msg = $e->getMessage();
     if ($msg[0] == '=') {
         $msg = substr($msg, 1);
         $explicit = true;
     } else {
         $explicit = false;
     }
     $error['message'] = $msg;
     $errorCode = $e->getCode();
     switch ($errorCode) {
         case Z_ERROR_INVALID_INPUT:
         case Z_ERROR_NOTE_TOO_LONG:
         case Z_ERROR_FIELD_TOO_LONG:
         case Z_ERROR_CREATOR_TOO_LONG:
         case Z_ERROR_COLLECTION_TOO_LONG:
         case Z_ERROR_CITESERVER_INVALID_STYLE:
             $error['code'] = 400;
             $error['log'] = true;
             break;
         case Z_ERROR_COLLECTION_NOT_FOUND:
             // 404?
         // 404?
         case Z_ERROR_TAG_NOT_FOUND:
             $error['code'] = 400;
             break;
         case Z_ERROR_UPLOAD_TOO_LARGE:
             $error['code'] = 413;
             $error['log'] = true;
             break;
         case Z_ERROR_SHARD_READ_ONLY:
         case Z_ERROR_SHARD_UNAVAILABLE:
             $error['code'] = 503;
             $error['message'] = Z_CONFIG::$MAINTENANCE_MESSAGE;
             $error['log'] = true;
             break;
         default:
             if (!$e instanceof HTTPException || $errorCode == 500) {
                 $error['code'] = 500;
                 if (Z_ENV_TESTING_SITE) {
                     $error['message'] = $e;
                 } else {
                     $error['message'] = "An error occurred";
                 }
             }
             $error['log'] = true;
     }
     if ($e instanceof HTTPException) {
         $error['code'] = $e->getCode();
     }
     return $error;
 }
Ejemplo n.º 22
0
 /**
  * Logs the original exception message.
  *
  * Provided as a manual override over the default `WP_DEBUG` dependent behaviour.
  *
  * @see Tribe__Exception::handle()
  *
  * @return bool  `true` if the message was logged, `false` otherwise.
  */
 private function log_original_exception_message()
 {
     if (!class_exists('Tribe__Log')) {
         return false;
     }
     $logger = new Tribe__Log();
     $message = $this->original_exception->getMessage();
     $log_type = $this->get_log_type_for_exception_code($this->original_exception->getCode());
     $src = $this->original_exception->getFile() . ':' . $this->original_exception->getLine();
     $logger->log($message, $log_type, $src);
     return true;
 }
Ejemplo n.º 23
0
 protected function responseException(\Exception $exception, $message, $key = '', $code = null)
 {
     $key = $key ? $key : 0;
     $code = $code ? $code : null;
     if (!$code) {
         $code = $exception->getCode() ? $exception->getCode() : null;
     }
     if (!$code) {
         $code = 500;
     }
     return $this->responseError([$key => $exception->getMessage()], $message, $code);
 }
Ejemplo n.º 24
0
 /**
  * @param \Exception $exception
  * @return string
  */
 private static function serializeException(\Exception $exception)
 {
     $appendix = '';
     $info = array_merge($exception->getMessage() ? array(self::serialize($exception->getMessage())) : array(), $exception->getCode() ? array(self::serialize($exception->getCode())) : array());
     if ($info) {
         $appendix = '(' . implode(', ', $info) . ')';
     }
     if ($exception->getPrevious()) {
         $appendix .= ' <- ' . self::serializeException($exception->getPrevious());
     }
     return self::serializeObject($exception, $appendix);
 }
Ejemplo n.º 25
0
 /**
  * @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;
 }
Ejemplo n.º 26
0
 /**
  * @param \Exception $e
  * @return int
  */
 private function getStatusErrorCodeFromException(\Exception $e)
 {
     switch ($e->getCode()) {
         //@TODO: complete list of supported status error codes
         case 400:
         case 405:
         case 404:
         case 422:
             return $e->getCode();
         default:
             return 500;
     }
 }
 /**
  * @return mixed
  */
 public function getStatusCode()
 {
     if (isset($this->exception)) {
         if ($this->exception instanceof HttpException) {
             return $this->exception->getStatusCode();
         } elseif (array_key_exists($this->exception->getCode(), Response::$statusTexts) && $this->exception->getCode() >= 400) {
             return $this->exception->getCode();
         } else {
             return Response::HTTP_INTERNAL_SERVER_ERROR;
         }
     }
     return $this->statusCode;
 }
Ejemplo n.º 28
0
 /**
  * Create a CQL Exception from various thrift & cassandra exceptions
  *
  * @param \Exception $e
  *
  * @return PdoException
  */
 public static function from(\Exception $e)
 {
     try {
         throw $e;
     } catch (\PDOException $e) {
         if (isset($e->errorInfo[2])) {
             return new self($e->errorInfo[2], $e->errorInfo[1], $e);
         }
         return new self($e->getMessage(), $e->getCode(), $e);
     } catch (\Exception $e) {
         return new self($e->getMessage(), $e->getCode(), $e);
     }
 }
 /**
  * Method to add the exception messages to the response array
  *
  * @param Form $form            
  * @return \AppBundle\Controller\AppController
  */
 protected function addExceptionErrors(\Exception $e)
 {
     $response = array();
     if ($e->getCode() === null) {
         $response['errorCode'] = self::EXCEPTION_ERRORS;
         $response['errorMessage'] = 'Unexpected Error! Please try later';
     } else {
         $response['errorCode'] = $e->getCode();
         $response['errorMessage'] = $e->getMessage();
     }
     $this->response = $response;
     return $this;
 }
Ejemplo n.º 30
0
Archivo: App.php Proyecto: ovide/phest
 public function errorHandler(\Exception $ex)
 {
     $ix = $ex instanceof Exception\Exception;
     $code = $ix ? $ex->getCode() : Response::INTERNAL_ERROR;
     $message = $ix || $this->devEnv ? trim($ex->getMessage()) : Response::$status[$code];
     //If $_devEnv is up shows also the debug trace
     $msg = $this->devEnv ? ['message' => trim($ex->getMessage()), 'code' => $ex->getCode(), 'type' => \get_class($ex), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace()] : ['message' => $message, 'code' => $code];
     $this->response->rebuild($msg, $code, $message);
     $this->response->encodeContent();
     /* @var $evt \Phalcon\Events\Manager */
     $this->_eventsManager->fire('micro:afterException', $this, $ex);
     return $this->response;
 }