Handles a database error
@param Exception $exception
@retun string $message
358682
protected function handleError($exception){
        $error = $this->queryBuilder->handleQueryException($exception);
        if($error[0] && isset($this->translations[$this->name][$error[0].'_'.$error[1]])) {
            $message = $this->translations[$this->name][$error[0].'_'.$error[1]];
        } else {
            $message = sprintf($this->translations['database']['query_error'],$error[0], $error[1]);
        }
        return $message;
    }
1119295
public function handle(\Exception $e) {

		try {
			ob_clean();
			$this->createResponse($e)->send();
		}
		
		catch(\Exception $e) {
			printf('Exception thrown when handling exception (%s: %s)', get_class($e), $e->getMessage());
			exit();
		}

	}
1276555
public function logErrorException(\Exception $e)
    {
        if ($this->getServerContext()->hasLogger(LoggerUtils::SYSTEM)) {
            $this->getServerContext()->getLogger(LoggerUtils::SYSTEM)->error($e->__toString());
        }
    }
694046
public function handle($exception)
    {
        $exception = call_user_func($this->config('exceptionCallback'), $exception);
        if (!$exception) {
            return;
        }
        $client = $this->client();
        $client = call_user_func($this->config('clientCallback'), $client);
        if ($client) {
            $client->notify($exception);
        }
    }
741744
public function handleException(\Exception $exception)
    {
        $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']);

        if ($isAjax) {

            $sEngine = Response\Factory::ENGINE_API;
            $sFormat = Response\Factory::FORMAT_JSON;
            $content = json_encode($exception->getTraceAsString());
        } else {
            $sEngine = Response\Factory::ENGINE_TEMPLATE;
            $sFormat = Response\Factory::FORMAT_HTML;

            if (EKA_ENV !== 'prod') {
                $contentHtml = '<b>Exception[' . $exception->getCode() . ']: ' . $exception->getMessage() . '</b><pre>' . $exception->getTraceAsString() . '</pre>';
            }

            $layoutPath = Config::getInstance()->get('Eureka\Global\Theme\php\layout');
            $themeName  = Config::getInstance()->get('Eureka\Global\Theme\php\theme');
            $content    = new Template($layoutPath . '/Template/' . $themeName . '/Main');
            $content->setVar('content', $contentHtml);
            $content->setVar('meta', Config::getInstance()->get('meta'));
        }

        $response = Response\Factory::create($sFormat, $sEngine);
        $response->setHttpCode(500)->setContent($content)->send();
    }
425476
public function log(Message $message, \Exception $e)
    {
        $sql = "UPDATE " . $this->messageTable . "
                SET log = :log
                WHERE message_id = :id
        ";
        $stmt = $this->getDb()->prepare($sql);
        $stmt->bindValue(':log', $e->getMessage(), \PDO::PARAM_STR);
        $stmt->bindValue(':id', $message->message_id, \PDO::PARAM_INT);
        $stmt->execute();
    }
570192
public function handleError(Exception $exception) {
        if (class_exists('Titon\Debug\Debugger')) {
            Debugger::logException($exception);
        }

        // Get the controller
        try {
            $controller = Registry::get('titon.controller');

            if (!($controller instanceof Controller)) {
                throw new MissingControllerException();
            }
        } catch (Exception $e) {
            $controller = new ErrorController();
            $controller->initialize();
        }

        // And the view
        try {
            $view = Registry::get('titon.view');

            if (!($view instanceof ViewInterface)) {
                throw new MissingViewException();
            }
        } catch (Exception $e) {
            $view = new View();
            $view->addHelper('html', new HtmlHelper());
            $view->addHelper('block', new BlockHelper());
            $view->addHelper('asset', new AssetHelper(['webroot' => $this->getWebroot()]));
        }

        $controller->setView($view);
        $controller->setRequest($this->getRequest());
        $controller->setResponse($this->getResponse());

        $this->emit('mvc.preError', [$this, $controller, $exception]);

        $response = $controller->renderError($exception);

        $this->emit('mvc.postError', [$this, $controller, $exception, &$response]);

        $this->getResponse()->body($response)->respond();

        $this->emit('mvc.onShutdown', [$this]);
        exit();
    }
900745
protected function logException(\Exception $exception)
    {
        try {
            $this->logger->error($exception->getMessage() , array('exception' => $exception));
        } catch (\Exception $exception) {
            trigger_error("Error logging Monitor exception: ".$exception->getMessage());
        }
    }
28730
public function setError($message, $code, $exception = null) {

        $trace = null;
        $extra = "";

        if ($this->get('debug', 0)) {
            if (isset($exception)) {
                $trace = $exception->getTrace();
                $extra = str_replace(JPATH_ROOT, "", $exception->getFile()) . ":" . $exception->getLine();
            } else {
                $trace = array_slice(debug_backtrace(), 2);
            }
        }

        $this->error = array(
            'message'   => $message,
            'code'      => $code,
            'backtrace' => $trace,
            'extra'     => $extra
        );
    }
889952
private function _failOnErrorAction(Exception $exception = null, $message = '', $level = Project::MSG_INFO)
    {
        if ($this->_failonerror) {
            throw new BuildException(
                $exception !== null ? $exception : $message,
                $this->getLocation()
            );
        } else {
            $this->log(
                $exception !== null && $message === '' ? $exception->getMessage() : $message,
                $level
            );
        }
    }
346694
private function handleException($exception, Message $message, array $options)
    {
        $headers = $message->getProperties();
        if (isset($headers['headers']['x-death'])) {
            $xDeathHeaders = $headers['headers']['x-death'];
            // PhpAmqpLib compatibility
            if ($xDeathHeaders instanceof AMQPArray) {
                $xDeathHeaders = $headers['headers']['x-death']->getNativeData();
            }

            $queueXDeathHeader = null;
            foreach ($xDeathHeaders as $xDeathHeader) {
                if (isset($xDeathHeader['queue']) && $xDeathHeader['queue'] === $this->queueName) {
                    $queueXDeathHeader = $xDeathHeader;
                    break;
                }
            }

            if (null === $queueXDeathHeader) {
                $this->logException(
                    $exception,
                    sprintf(
                        '[XDeathMaxLifetime] No x-death header found for queue name "%s". Do nothing.',
                        $this->queueName
                    ),
                    $options['x_death_max_lifetime_fail_log_levels_map']
                );
            } elseif (isset($queueXDeathHeader['time'])) {
                $xDeathTimestamp = $queueXDeathHeader['time'];
                if ($xDeathTimestamp instanceof \DateTime || $xDeathTimestamp instanceof \AMQPTimestamp) {
                    $xDeathTimestamp = $xDeathTimestamp->getTimestamp();
                }
                $remainLifetime = $xDeathTimestamp - (time() - $options['x_death_max_lifetime']);
                if ($remainLifetime <= 0) {
                    $this->logException(
                        $exception,
                        sprintf(
                            '[XDeathMaxLifetime] Max lifetime reached. %s/%s seconds exceed. Execute the configured callback.',
                            abs($remainLifetime),
                            $options['x_death_max_lifetime']
                        ),
                        $options['x_death_max_lifetime_fail_log_levels_map']
                    );

                    if (null !== $return = \call_user_func($this->callback, $exception, $message, $options)) {
                        return $return;
                    }
                } else {
                    $this->logException(
                        $exception,
                        sprintf(
                            '[XDeathMaxLifetime] Lifetime remain %d/%d seconds.',
                            $remainLifetime,
                            $options['x_death_max_lifetime']
                        ),
                        $options['x_death_max_lifetime_log_levels_map']
                    );
                }
            }
        }

        throw $exception;
    }
1243716
private function handleException(\Throwable $exception, Message $message, array $options)
    {
        $this->client->captureException($exception, $this->buildSentryData($message, $options));

        throw $exception;
    }
213421
protected function logException(\Exception $exception, $message)
    {
        if (null !== $this->logger) {
            if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
                $this->logger->critical($message, array('exception' => $exception));
            } else {
                $this->logger->error($message, array('exception' => $exception));
            }
        }
    }
600680
protected function triggerError ($errorMessage)
	{
		$this->hasError 	= true;
		$this->errorMessage	= $errorMessage;
		
		throw new Exception ($errorMessage);
	}
637889
public function error($msg, \Exception $e = null) {
		foreach($this->loggers as $logger)
			$logger->error($msg, $e);
	}
527551
public function handleException(Exception $exception)
    {
        try {
            while (ob_get_level()) {
                ob_end_clean();
            }

            $code = 500;
            if (is_subclass_of($exception, 'Rad\\Core\\Exception\\BaseNetworkException')) {
                $code = $exception->getCode();
            }

            http_response_code($code);
            echo $this->handler->handle($exception);

            return;
        } catch (Exception $e) {
            $message = sprintf(
                "[%s] %s\n%s",
                get_class($e),
                $e->getMessage(),
                $e->getTraceAsString()
            );

            trigger_error($message, E_USER_ERROR);
        }
    }
522566
protected function handleException($exception) : void
    {
        $previous = $exception->getPrevious();

        if ($exception instanceof QueryException) {
            throw new $exception($exception->getMessage(), $exception->getBindings(), $previous);
        }

        throw new $exception($exception->getMessage(), $previous);
    }